Any advantage of moving default docker directory from /var/lib/docker to a different partition or data drive?

  • (New install, newbie Q, excuse me if maybe I'm not asking it the right way)

    My concerns, feel free to shut them down

    • Will /var/lib/docker ever get extremely big from docker data?
    • Is this extra stress on the OMV OS drive?
    • Is it necessary to backup this folder for a future restore, I imagine, it'll be easier to backup a shared folder different drive
  • (New install, newbie Q, excuse me if maybe I'm not asking it the right way)

    My concerns, feel free to shut them down

    • Will /var/lib/docker ever get extremely big from docker data?
    • Is this extra stress on the OMV OS drive?
    • Is it necessary to backup this folder for a future restore, I imagine, it'll be easier to backup a shared folder different drive

    It's possible that /var/lib/docker will swell to consume your entire OS disk and break everything. But it's highly dependant on which containers you are running, and how many. If you can't predict what your use case will become, it's best to just not use the rootfs for this.


    I would say using the rootfs for this can be stressful to the drive. A sane OMV OS setup will write little to the OS drive, and a lot of that can be mitigated with the Flash Memory plugin. If you are running OMV from an SD card, it will likely die early if you use /var for docker stuff.


    Backing up /var/lib/docker (or an alternate location on a different drive) may or may not make sense. If the content is constantly changing, then a restore from a backup might not work. I don't back this up. I back up the docker creation commands that created the containers so they can be easily recreated. The assumption is that the data the containers generate is either also backed up or is not critical enough to require being backed up.


    Best advice I have for you is to not even start with anything docker related anywhere on your rootfs.

    --
    Google is your friend and Bob's your uncle!


    OMV AMD64 7.x on headless Chenbro NR12000 1U 1x 8m Quad Core E3-1220 3.1GHz 32GB ECC RAM.

  • this directory can get quite big:



    the main contents is epermal storage of running containers, downloaded image and volumes

    the only thing you should backup is the volumes.


    Do not backup the directory, but use a proper backup for your volumes:


    In order to backup volumes you have to use the cli and these commands (here i demontarate how to backup portainer_data)

    • Stop container using
      docker stop portainer
    • Create the backup of the volume into a compressed tar file
      FROM=portainer_data docker run --rm -v ${FROM}:/from alpine sh -c "tar -z -c -p -O -C /from . " > ${FROM}.tgz
      This command spins up a container, mounts the target volume at /from, creates a tar file and writes it to a file.
    • Restart portainer
      docker start portainer


    In order to restore the volume from a compressed tar file:

    • Stop portainer
      docker stop portainer
    • Delete all files in the volume and restore from backuop
      TO=portainer_data; cat portainer_data.tgz | docker run -i --rm -v ${TO}:/to alpine sh -c "cd /to && rm -rf * && tar zx"
      This command pipes the backup into a container which will clean the target volume and decompress the files to it.
    • Restart portainer
      docker start portainer


    In this forum many bind directories into the docker containers which can be backed up using normal file backup.


    But remember, for many containers you only get consistent backups when you stop the containers during backup.

    If you got help in the forum and want to give something back to the project click here (omv) or here (scroll down) (plugins) and write up your solution for others.

    • Official Post

    Add to what was already said by gderf and Zoki:

    - Execution speed. You can safely have OMV installed on a USB drive, so if docker is on an SSD drive the performance of the installed programs will be higher.

    - In a USB drive the data is written rotating the empty space. The more empty space your USB drive has where OMV is installed the longer it will take to fail. Flash drives have a maximum number of writes before failure.


    This is my recommendation on how to configure docker, in case it works for you. [How to] Prepare OMV to install docker applications

Participate now!

Don’t have an account yet? Register yourself now and be a part of our community!