Move docker storage location

  • Hi,


    I have an sdd connected to rpi4 that I use for docker. I have set the docker storage path to this disk. The mainly docker image used is nextcloud that I have been running smooth for like 1 year. Now I want to replace the 128GB that is almost full with a 512GB disk.


    How should I proceed with this?

    Can I dd from one disk to another and then expand the disk?

    Should I rsync all the files from one to another?


    Thank you

    • Offizieller Beitrag

    Connect your new disk to the Pi and format and mount it so you can use it.


    Stop the docker service


    Code
    systemctl stop docker

    Once docker is stopped, copy your containers folder over to the new drive (I'm assuming you're doing this at command line)


    Code
    cp -R /old/path/folder_name /new/path/folder_name

    Let it finish. This may take some time depending on the size of your containers folder, etc. (usually when I back mine up, it's around 20min on platter drives)


    When it's done, go to the docker plugin in OMV

    Under Settings, change the path to the /new/path/folder_name

    Click Save (this is important)


    Click Install Docker. Docker is already installed on your system, so it's not really going to do anything other than update the the docker config file with the new container path and then restart the service.


    Once the service restarts, check that the service has started properly without error. (it should say "active" and "running" at the top)


    Code
    systemctl status docker

    Now you can verify docker is checking your new path

    Code
    docker info | grep Root


    Once youv'e confirmed docker is running again on the new path, check your containers (nextcloud, etc.) and make sure they are all functioning normally.. .they should be.


    After you've confirmed everything has transferred over and your containers are working properly...


    Delete your old containers folder off the old drive to reclaim the space. Do not delete it until you've verified everything is working correctly. That's why in this case I recommend copying the folder, rather than moving it when you can.... that way if something goes fubar... all you have to do is change the path back to the original folder.


    Edit: I just realized you had more than just docker on that drive.... Well how I detailed above is how I'd move docker. For the other files.. I usually just use rsync... When it's all done, just format the old drive.

  • Edit: I just realized you had more than just docker on that drive.... Well how I detailed above is how I'd move docker. For the other files.. I usually just use rsync... When it's all done, just format the old drive.

    I only have docker on that driver but I have mutiple containers running. When I'm home I can share a ls of the disk. cp command keep all the owners and permissions?


    Thank you for the detailed explanation :)

    • Offizieller Beitrag

    I only have docker on that driver but I have mutiple containers running. When I'm home I can share a ls of the disk. cp command keep all the owners and permissions?


    Thank you for the detailed explanation :)

    if you want to retain permissions (didn't really think about that).. you would use the -rp switch:


    Code
    cp -rp /old/path/folder_name /new/path/folder_name


  • Hi, needed to install docker and portainer at the end. I was very cautious during the process and it is working with the new ssd :D


    Change the cp -rp with cp -rav. -v to know what cp is doing and -a because reading the man page it looks like it perserve more information.


    Thank you for the guide :)

  • metRo_

    Hat das Label gelöst hinzugefügt.
  • Hey there, I moved my docker base folder to another drive this way too, but it didn't work correctly.

    I have two docker folders. The main docker storage folder and one for my containers external data, eg plex data.

    The external apps data folder works fine and I haven't moved it.
    After I moved the docker folder and reinstalled docker etc, I had to reinstall Portainer to gain access. When I log in all my other containers have exited and won't start. There's also no "Edit Container" button where I can re-pull the images etc.

    I'm assuming there must be more directory settings that need updating for the individual containers, but i'm not sure where to look.
    Any help would be amazing.


    Thanks B :)

    • Offizieller Beitrag

    Hey there, I moved my docker base folder to another drive this way too, but it didn't work correctly.

    I have two docker folders. The main docker storage folder and one for my containers external data, eg plex data.

    The external apps data folder works fine and I haven't moved it.
    After I moved the docker folder and reinstalled docker etc, I had to reinstall Portainer to gain access. When I log in all my other containers have exited and won't start. There's also no "Edit Container" button where I can re-pull the images etc.

    I'm assuming there must be more directory settings that need updating for the individual containers, but i'm not sure where to look.
    Any help would be amazing.


    Thanks B :)

    All this does, is move the docker folder... that's it.


    If your containers have new paths for their volumes.... then as I said this will not work. I suspect this is the problem since OMV does not mount by labels anymore, the way it did in OMV 4. It mounts by UUID


    Example... Say Jellyfin has


    /srv/disk-by-label-SOME_LABEL/jellyfin:/config for it's config.


    However now on OMV6, the drive mounts via UUID, so that path will be


    /srv/disk-by-uuid-123456789/jellyfin:/config


    Well, now your jellyfin container cannot see those paths. So when you point at docker, it's not going to see those folders. I can't say for sure this is your problem, but it seems likely, IMO.

    This is a good argument for using symlinks in your stacks/docker-compose files, as you can keep them consistent no matter what the UUID of the source drives are.

  • Hey, so I tried following your instructions again. I confirmed the new directory is being used etc. I'm on OMV5 and all my drives are labeled with UUID. I use the symlinks plugin for some things but not docker as I've had issues using symlinks in docker before. I always make sure to use UUID in my potainer/containers. However, again, after reinstalling docker with the new path, I had to re-install portainer as it wasn't working anymore. All other containers have exited except for the newly installed portainer.

    I'm a pretty basic user when it comes to docker, so I need to educate myself on what stacks are :S ... In saying that, I have zero stacks in Portainer. I use portainer for everything docker, and there's never been any stacks listed in portainer.



  • I've tried multiple times now with the same results. I also tried copying the files to the new location after I modify the docker path address. I thought (maybe) the changes might not be replicated to the new directory. I don't know what else to try. Will I just have to rebuild all the containers manually?

  • I've tried multiple times now with the same results. I also tried copying the files to the new location after I modify the docker path address. I thought (maybe) the changes might not be replicated to the new directory. I don't know what else to try. Will I just have to rebuild all the containers manually?

    look I did it a while ago and everything works for now ... I don't understand what's wrong with you

Jetzt mitmachen!

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