Docker Community Forums

Share and learn in the Docker community.

Need advice on moving large docker container to another server

Hi,

I have a docker container that is around 160GB in size (virtual/total size).

I need to move this container to another server.

I understand that I could save the container into a docker image, copy the image into another server, then revive the container on the new server.

Considering the large size of the container, is there a way to move it to another server without having to save it to an image?

Our challenge is:

  • disk space, there may not be enough space in the current server to do commit plus save the image
  • down-time, would like to minimize down time while the container is committed and saved to image

Also, what’s the best way to investigate what’s the 160GB is used for in the container? i.e: is the docker framework itself use a lot of disk space?

Thank you so much in advance for any inputs.

How have you been able to have a container with 160GB?

Seems like you did not map any docker volumes (from host or remote shares like nfs/cifs) into your container to store persistent data there… Did you?

Containers are supposed to be ephemeral/dispossable, as such the normal approach would be to throw away the container and backup the source of the docker volume. if I understood you right, in your case those would mean a total loss of data.

If you didn’t persist data in volumes, then there is no way around this! Once you create a container based on the image of your old containers export, you should consider working with volumes. They make like easier and less risky coug

Thank you for the input.
We were kind of new to docker back then and was stuck with the situation.

Is there any safe way to add a mount a new volume to an existing docker container?

Maybe that way I can create a new volume, mount it within the current container, and migrate the data from the container into the volume.

Nope, there is no way to add/remove a volume to an existing container.

If you are lucky, the image declares one or more volumes that you didn’t map to a volume. If so, the data might be stored in /var/lib/docker/volumes/?/_data.

Please share the output of this command:

docker inspect --format '{{ range .Mounts }} host: {{.Source }} -> container: {{.Destination}}{{ printf "\n" }}{{ end }}'  {containerid}

For some reason the command line you gave result in blank lines.

I did a plain docker inspect and noticed “Mounts”: , i.e: empty mounts.

Is there particular section I need to look at to determine if there’s unused volume mount point I can piggy back?

Well, if mounts is empty then its to be expected that the command gives an emtpy result.

I am afraid you only solution is docker export/docker import.Good luck!

Update: try to check if your files are available via merged dir. You can find the location with docker inspect --format '{{ .GraphDriver.Data.MergedDir }}' {containerId}.

@meyay Thank you so much for the input!

1 Like