Migrating docker instance to another server

1.2k Views Asked by At

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.

1

There are 1 best solutions below

2
On BEST ANSWER

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

  • Bind mounts: these can be used by mounting a specified directory from the host system into your docker container ( could be outside of /varlib/docker in your case )

  • Named volumes: Volumes are the preferred mechanism for persisting data generated by and used by Docker containers. The default location is /var/lib/docker on linux

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.