How to duplicate running docker container

Mahabub picture Mahabub · Mar 9, 2018 · Viewed 13.1k times · Source

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?

Answer

larsks picture larsks · Mar 9, 2018

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