How to duplicate running docker container

19,250

Solution 1

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

Solution 2

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).

Share:
19,250

Related videos on Youtube

Mahabub
Author by

Mahabub

Updated on June 04, 2022

Comments

  • Mahabub
    Mahabub almost 2 years

    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?

  • Mohammad Faisal
    Mohammad Faisal over 3 years
    the argument is --volumes-from not --volumes -from.