I have a docker container running
> docker container ls
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
c5a24953e383 gradle "bash" 22 minutes ago Up 22 minutes # naughty_torvalds
Can I duplicate this running container and run it? What is the command for it?
To 'clone' a container, you'll have to make an image of that container first, you can do so by "committing" the container. Docker will (by default) pause all processes running in the container during commit to preserve data-consistency. Commit my_container as an image called my_container_snapshot , and tag it yymmdd .
Description. The docker cp utility copies the contents of SRC_PATH to the DEST_PATH . You can copy from the container's file system to the local machine or the reverse, from the local filesystem to the container.
You can create a new image from that container using the docker commit
command:
docker commit c5a24953e383 newimagename
And then start a new container from that image:
docker run [...same arguments as the other one...] newimagename
You can use:
docker run --name duplicateImage --volumes-from Image -d -p 3000:80 nginix:latest
The --volumes-from Image
duplicates the 'Image' container.
So you will now have a container named Image and a container named duplicateImage and they will contain the same image that is running (a container).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With