Moving the Docker package from one volume to another on Synology
There's a lot of info out there about moving docker from one volume to another. Almost all of it unfortunately is for systems which differ from DSM, and although still Linux, do have some significant changes.
The below will run through how to move the package across volumes, and some of the work you may need to do afterward. It's worth noting that this will initially remove the docker package and all your containers, but not to fear, they're easily recreated.
Prerequisites
- SSH access to your NAS (click the link if you don't know how to do that)
- A way to recreate your containers, such as Portainer, the
docker-compose.ymlfiles for your containers stored somewhere secure, or thedocker runcommands you previously used - Sudo/root access (normally by using the same password as any user with admin permissions)
- Access to DSM
docker-autocompose to create compose files from all your running containers. You can find the github repo for the project hereBackup backup backup
BEFORE we uninstall docker, backup your docker ecosystem now. We shouldn't need the backups, this is just in case. Separate to any mapped folders you may have, the following directoires also need to be backed up (assuming you installed docker in /volume1) :
/volume1/@docker/volumes/volume1/@docker/network/volume1/@appstore/ContainerManager
/volume1/@appstore/ContainerManager is for those using DSM 7. If you are still using DSM 6, this will be /volume1/@appstore/Docker- We backup
volumesas it has all of the data that our containers created which weren't mapped to the local drive - We backup
networkas it stores the database of all our docker networks - We backup the appstore
ContainerManager(orDocker) folder just in case. I don't expect we'll need to use it
Also make sure as previously stated that you know how to recreate your containers.
Uninstalling docker
Now we're ready to begin the process.
- Log in to DSM and stop, then uninstall, your docker package (it's up to you if you want to stop your containers first)
- In the pop up, DO NOT tick the box next to 'Delete the items listed above...'. We still want the docker shared folder (at least for now)

Reinstalling Docker
You did it before, so I'm assuming you can do it again, however this time:
- In the pop up modal just after you click
Install, make sure you click theVolumedrop down box and select the volume you want to install it in. For my purposes I'm going to assume moving forward it isvolume2
Repointing the symlink
The docker target is automatically stored in /var/packages/ContainerManager/target, but this isn't a file you can change. Just reinstalling the docker package doesn't change this file either, so we need to do a few things (again assuming your new docker package is on volume2:
- SSH into your machine with an admin-level user
- Type
sudo -ito get root access and then type in your password when prompted - Check that docker is using
/volume2by typingdocker info. The output should include a lineDocker Root Dir: /volume2/@docker - To repoint your docker target to volume2, copy paste the following
ln -s /volume2/@appstore/ContainerManager /var/packages/ContainerManager/targetYou won't get an output from this command
Recreating your docker networks
This should be as simple as copying across your network directory we backed up earlier:
rsync -avh /volume1/@docker/network /volume2/@docker/I prefer this rsync command as it keeps all source directory permissions, and shows a verbose output
Now if you type a docker network inspect command, you should get an ouput which includes your previous networks.
Recreating your containers
You should now be able to recreate your containers in exactly the same way as before, without having to move any of your container config folders.
But what about the volumes created by the containers?
- Spin up the container which has a created volume
- When the container is running, copy the relevant directory in
/volume1/@docker/volumesto overwrite the one that was created in/volume2/@docker/volumes
authentik_volume created by the container, I will copy (with permissions) the same folder across from volume1 using the following command:rsync -avh /volume1/@docker/volumes/authentik_volume /volume2/@docker/volumes/Hint: to copy across more than one folder, you can use { } brackets in the following format:
rsync -avh /volume1/@docker/volumes/{folder1,folder2,folder3} /volume2/@docker/volumes/What about all my container config data still on volume1?
It's now up to you if you want to move none, some or all of your config and data folders across to volume2. Just remember that if you do, you will need to modify any of your docker-compose or .env files to mirror those changes, otherwise the next time you try and update the image you'll run into problems.
Similarly, make sure you use a command which keeps all source folder permissions (like the rsync -av commands above) so that you don't run into any issues.
Related Articles


