We have a forum application made of two containers: a container for the database, and another one for the bulletin board application itself. Both containers are running on the same host for quite some time now. That application does not follow the "microservice" architecture since the database files are stored in the writable layer of the database container. And the configuration settings of the forum were directly set up in the writable layer of the bulletin board application.

We would like to migrate that forum to a different host since the current server has reached end-of-life. We see two ways of doing that:

  • using docker commit to make an image of both containers, then uploading those images to a repository and pulling them back from the new host.
  • using docker export to create archives of the container filesystems, and importing them on the new host.

What are the pro and cons of both approaches for ad-hoc container migration? Is there a better-suited solution for our specific needs?

  • 1
    – Marged
    Commented Feb 14, 2019 at 6:42
  • @Marged yes, I've seen that. But the problem is not about knowing which command I can use. But which one I should use. Said simpler, is there a specific advantage in committing the image I would miss by merely exporting a tarball? Commented Feb 14, 2019 at 11:59
  • I think the advantages are mentioned rather clearly. At least when it comes to speed, size and completeness
    – Marged
    Commented Feb 14, 2019 at 17:10

1 Answer 1


From what I understand of https://stackoverflow.com/questions/28734086/how-to-move-docker-containers-between-different-hosts, docker export will only save the container filesystem. But no metadata such as the default command, leading to that error when you try to run the imported archive:

sh# IMAGE=$(docker import phpbb.tar)                                                                                                                                       
sh# docker run "${IMAGE}"
docker: Error response from daemon: No command specified.

Given my need, it is sufficient to docker commit the container to a new image, then docker save the image, and finally docker load and docker run it on the new host:

old# docker commit CONTAINER name:tag
old# docker save name:tag |gzip > archive.tar.gz
old# scp archive.tar.gz root@new:.
new# docker load < archive.tar.gz
new# docker run name:latest

It is important to save the image by repository name:tag and not by id to preserve the tag in the archive.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.