Alpha
Alpha

Reputation: 14026

How to copy entire container?

I run container on one of the 3 machines(which is dynamically picked up by pipeline) and there I'm facing issue with server startup and to analyze the failure I need another person's help but considering his availability I cannot say when he will be available.

And also I cannot keep occupied that host machine on which container is running as other members on team need it.

Also next time, when developer is available, I'll have to trigger build and take it to that stage where I can show issue to developer, but again that will take time.

In this case, is there any way, I can stop that container and take entire copy of it and next time when needed run it so I'll have container in a state which is needed and also this is less time consuming.

Upvotes: 1

Views: 1134

Answers (1)

Pierre B.
Pierre B.

Reputation: 12923

You can create a Docker image based on an existing container with docker commit, such as:

docker commit my-container image-from-my-container
# return an image SHA

You can then run a container based on your commited image (matching your container state when it was commited)

docker run [OPTIONS] image-from-my-container

If you also need to export your image to another machine (as another team member may need the original machine), you can either:

  • Push the image to a distant registry with docker image push and run it from another machine
  • Export your image to a TAR file with docker image save image-from-my-container > saved-image.tar, download the archive to another machine, then load it with docker image load -i saved-image.tar

Upvotes: 2

Related Questions