linuxdockeroverlayfs

Migrating docker instance to another server


I am trying to migrate an existing docker installation to a new server. I created a tar file from /var/lib/docker from the old host and unpacked the tar folder on the new host in /var/lib/docker.

It seems most space is utilized by the next folders:

/var/lib/docker/containers
/var/lib/docker/overlay2
/var/lib/docker/volumes

When starting the docker service on the new host i can start my old containers. BUT they do not contain any data. Is it possible to somehow get my old containers running on the new hosts and keeping their data persistent?

Once running on the new server I can create new containers and start using persistent volumes.


Solution

  • You need to check on the old server to see how / where the mounts are. docker has various mounting methods,

    Now to figure this out you can use docker inspect <container id/name> on the old host. there volumes and mounts sections in the output that can give you ideas what more you may need to backup and restore.