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

  • It look like moving docker folder even with a link break the system @votdev knew of course what was the problem
    Cannot create shared folder on new or existing drive
    Anyway on a new install if I use my old docker installed on a different drive I cannot create a share folder but if I stop the docker service and use the original regular docker folder in var lib (even without docker created) I can create the share folder.


    but I think yesterday I try on my old system to copy the docker folder back to var lib but the result was the same was not able create a share folder make me wonder if some thing wrong with my docker! I am going to investigate a little bit more!

  • OK. Let's continue.
    1. service docker stop
    2. rsync -avr --progress /var/lib/docker /sharedfolders/hdd_temp/ rsync -avr --progress /var/lib/docker /srv/dev-disk-by-label-HDD/hdd_temp/
    3. /var/lib/docker renamed to /var/lib/docker.old
    4. ln -s /sharedfolders/hdd_temp/docker /var/lib ln -s /srv/dev-disk-by-label-HDD/hdd_temp/docker /var/lib


    service docker start gives error.
    what is wrong?



    If i delete /var/lib/docker symlink and return /var/lib/docker.old to /var/lib/docker then start is successful

  • You do not want to use a shared folder for that purpose. Use the actual fully qualified path name instead.

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

  • You do not want to use a shared folder for that purpose. Use the actual fully qualified path name instead.

    i don't understand. how not to use sharedfolder? same problem if i use /srv/dev-disk-by-label-HDD/hdd_temp/docker
    can you provide correct example on my case?

  • Look in (edit) /etc/docker/daemon.json Write down what's in there or make a copy of the file if you will be changing it.


    Try changing the "data-root" path to be here if that's where you want it:


    /srv/dev-disk-by-label-HDD/hdd_temp/docker


    If you haven't done so yet you will have to stop the docker service and copy all the contents of /var/lib/docker to /srv/dev-disk-by-label-HDD/hdd_temp/docker


    Restart docker service or reboot when done.

    --
    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 know... still nothing helps, Docker does not start from symlinked directory..
    Editing daemon.json with a link to new directory does not help.
    Should I just to start over from clean docker and setup packages with new directory?


    May be some package blocking process? i will try to check it after deleting one-by-one.

  • Are you absolutely sure that the docker service was stopped before you made any changes?

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

  • OK i have some investigations. If i delete btrfs folder (with 'subvolumes' folder inside) then docker starts easy, just without containers. After copy btrfs whole folder docker not starts.
    All other folders also copied and docker starts without problems. But not with my saved btrfs. What is wrong with that folder and how correctly move it to new folder? Is a "rsync -avr --progress" moves it wrong way?


    also, i've found a can use
    {
    "data-root": "/srv/dev-disk-by-label-HDD/hdd_temp/docker",
    "storage-driver": "overlay2"
    }


    in daemon.js
    Works good even without symlink. But it's too late, i'am using default damned btrfs and my saved subvolumes on it. So how to move it properly to new place?

  • I would like to change my base path for docker too. So to now, what's the working procedure?


    1. Disable docker service

    2. Copy var/lib/docker into a shared folder created ad hoc on my HD (where i store also other data)

    3. Create link between old and new base path

    4. Delete old base path


    ?

  • I would like to change my base path for docker too. So to now, what's the working procedure?

    whats the path of your HD? Mean is it a netshare or an local hd on the docker machine? if second one is it mounted already?


    as example for an internal HD on the docker host:


    1. stop docker

    2. move content of /var/lib/docker to the new location

    3.

    Code
    rm -rf /var/lib/docker #deletes old docker folder
    ln -s /yourhdpath/docker /var/lib/docker #symlink new folder to old location


    if linking not work, maybe give this a shot:

    Code
    mount --bind /yourhdpath/docker /var/lib/docker

    4. start docker.


    well, i didnt tested that but theoretically it should work. Please make a backup before!!

  • Thanks for your reply!


    It's an HD i've connected to my ODROID HC2 and i have samba shares on it. I store config folders in AppData shared folder on the disk and now i have created another shared folder called DockerBasePath. So yes it's already mounted.


    Copied with "cp -R /var/lib/docker /srv/dev-disk-by-label-HC2/DockerBasePath". But i see with "du -sh" that the size of the original docker dir is 7.1G, instead the "new" one is 10G. How is possible?


    Two things:

    1. from windows i can't access the docker dir i just copied, maybe because it's only for root? How could i fix permissions on it? Strange because i enabled inherited permissions on the DockerBasePath shared folder.


    2. so to now i have on my share: /srv/dev-disk-by-label-HC2/DockerBasePath/docker. Is this ok or i should put the content of docker directly under DockerBasePath?

Jetzt mitmachen!

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