Move docker /var/lib/docker folder on external drive

  • Hi all,
    I'm running OMV on a raspberry pi2 using a 8GB microSD card.
    root filesystem is running out of space.
    /var/lib/docker folder uses 2,6GB of disk space.
    Can I move this folder to an external storage?

  • In OMV go to Services | Docker | Settings. Make a change to the setting: The location of the Docker base path. This must be an OMV shared folder, so create one on the target drive beforehand if you have not already done so.

    --
    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.

  • I don't think that changing the docker base path deletes the files from the old location.

    --
    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.

  • I have very bad experience with changing this setting. During one of the updates of Docker addon i received bunch of folders (docker related) in /sharedfolders/
    + the setting was back to default which created a complete mess ....


    So my solution is :


    1) don't touch the setting in Docker tab
    2) Move /var/lib/docker to external drive (ex. /sharedfolders/data/docker)
    3) sym-lync /sharedfolders/data/docker to /var/lib/docker


    Done.


    No problems so far....

  • I am very interested to move my dockers to my external drive just need to know the pros and cons for doing it, and above all, what is the way to create a symlink in order to achieve this.

  • You can create symlinks with ln -s


    https://linux.die.net/man/1/ln

    Well I have to confess,i am not too good to navigate in cmd i did actually succeed but gave an existent link.So in order to create the link so I used win scp and cmd
    but now my docker place is empty I renamed the link docker but nothing
    I did try this


    root@rockpro64:/sharedfolders# ln -s /docker /var/lib/docker-link
    but it is wrong what could be the exact cmd?

  • I am replying to myself!
    This time I stopped the plugin succeed to navigate to the appdata folder where I had copied the docker folder from var/lib and did the cmd ln -s /docker /var/lib/docker
    so far it is working before deleting the original docker I renamed it old the only difference all my docker images is empty but not the docker container witch show only numeric ID maybe because of towerwatch or some error I produced a long the way.
    I am unable to download the new images but I have connection to the repo!

  • The main issue for me is to get a proper copy of my original docker in my appdata folder but I only get only a partial copy of the docker folder I am using


    rsync -avr --progress /var/lib/docker /sharedfolders/AppData/data/docker
    and after for the link ln -s /docker /var/lib/docker but probably this is not right
    Should I put back the noexec I modified some time ago for plex problem?
    Actually i corrected my link but it look like I am getting a virgin docker folder instead
    ln -s /sharedfolders/AppData/data/docker /var/lib/docker/docker

  • I continue my monologue this time I think it is working, the problem was too many docker nested into each other
    so I had to change my link
    ln -s /sharedfolders/AppData/data/docker/docker /var/lib/docker
    Well at least I am learning CLI.


    Hi, I am trying to do the same as you. It would be handy for me to be able to remove the SD-card out of my RockPro so that I can put new images on it, without having to reinstall all the dockers.


    I did the following:


    First I created a Shared Folder in webgui: DockerData
    The I ran (as root)
    mv /var/lib/docker /sharedfolders/DockerDataln -s /sharedfolders/DockerData/docker /var/lib/docker


    But when I tried to install a new Docker I get the following error message:


    Failed to execute command 'export PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin; export LANG=C.UTF-8; docker run -d --restart=always -v /etc/localtime:/etc/localtime:ro --net=host -e PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin" --name="watchtower" --label omv_docker_extra_args="-v /var/run/docker.sock:/var/run/docker.sock" -v /var/run/docker.sock:/var/run/docker.sock "containrrr/watchtower:latest" 2>&1' with exit code '125': ce4b09904a5cc1ecee4bfe2a82261a3f852e8949b8a9a45768ba9f04ed032790docker: Error response from daemon: OCI runtime create failed: /var/lib/docker/overlay2/42adf7a818ee0fa1dc7ac7f1a5dd209f5669ab56be76ac5e3745375ef9ba7430/merged is not an absolute path or is a symlink: unknown.

    Code
    Error #0:
    OMV\ExecException: Failed to execute command 'export PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin; export LANG=C.UTF-8; docker run -d --restart=always -v /etc/localtime:/etc/localtime:ro --net=host -e PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin" --name="watchtower" --label omv_docker_extra_args="-v /var/run/docker.sock:/var/run/docker.sock" -v /var/run/docker.sock:/var/run/docker.sock "containrrr/watchtower:latest" 2>&1' with exit code '125': ce4b09904a5cc1ecee4bfe2a82261a3f852e8949b8a9a45768ba9f04ed032790
    docker: Error response from daemon: OCI runtime create failed: /var/lib/docker/overlay2/42adf7a818ee0fa1dc7ac7f1a5dd209f5669ab56be76ac5e3745375ef9ba7430/merged is not an absolute path or is a symlink: unknown. in /usr/share/php/openmediavault/system/process.inc:182
    Stack trace:
    #0 /usr/share/openmediavault/engined/rpc/docker.inc(607): OMV\System\Process->execute()
    #1 [internal function]: OMVRpcServiceDocker->runContainer(Array, Array)
    #2 /usr/share/php/openmediavault/rpc/serviceabstract.inc(123): call_user_func_array(Array, Array)
    #3 /usr/share/php/openmediavault/rpc/rpc.inc(86): OMV\Rpc\ServiceAbstract->callMethod('runContainer', Array, Array)
    #4 /usr/sbin/omv-engined(537): OMV\Rpc\Rpc::call('Docker', 'runContainer', Array, Array, 1)
    #5 {main}


    So for some reason it finds it a problem that this is a symlink. How did you get around this?

    I run OMV on a RockPro64 (4GB RAM).
    OMV version 4.1.23-1 (Arrakis)
    Kernel: Linux 4.4.167-1213-rockchip-ayufan-g34ae07687fce
    Processor: ARMv8 Processor rev 2 (v8l)


  • I did this not avoid to recreate docker but to avoid the wear and tear of the SD with to many I/O rewrite card the MV command did not work for me maybe a permission issue
    so I used
    Rsync
    rsync -avr --progress /var/lib/docker /sharedfolders/AppData/data/docker
    and to create a link ln -s /sharedfolders/AppData/data/docker/docker /var/lib/docker


    you can click the symlink in winscp ifthe path oper to the docker
    And when I was sure everything was working I deleted the original Docker folder.

  • Thanks for answering. My solution was that I had to run


    service docker stop


    before I did the rest. This is also the case when I want to add or remove any shared folders. And then after you have to run


    service docker start


    of course.


    My source: https://forums.docker.com/t/ho…stallation-directory/1169


    I can really recommend doing this for people that flash their images on a sd-card!

    I run OMV on a RockPro64 (4GB RAM).
    OMV version 4.1.23-1 (Arrakis)
    Kernel: Linux 4.4.167-1213-rockchip-ayufan-g34ae07687fce
    Processor: ARMv8 Processor rev 2 (v8l)

  • How do you can (re)move docker folder? subfolder btrfs cannot be moved or deleted

    Is the docker service stopped?

    --
    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.

Jetzt mitmachen!

Sie haben noch kein Benutzerkonto auf unserer Seite? Registrieren Sie sich kostenlos und nehmen Sie an unserer Community teil!