Multiple Docker containers, same image, different config

前端 未结 3 1471
栀梦
栀梦 2020-12-08 02:33

I\'m totally new to Docker so I appreciate your patience.

I\'m looking for a way to deploy multiple containers with the same image, however I need to pass in a diffe

3条回答
  •  有刺的猬
    2020-12-08 03:08

    Just run from the same image as many times as needed. New containers will be created and they can then be started and stoped each one saving its own configuration. For your convenience would be better to give each of your containers a name with "--name".

    F.i:

    docker run --name MyContainer1 
    docker run --name MyContainer2 
    docker run --name MyContainer3 
    

    That's it.

    $ docker ps
    CONTAINER ID        IMAGE            CREATED          STATUS               NAMES
    a7e789711e62        67759a80360c   12 hours ago     Up 2 minutes         MyContainer1
    87ae9c5c3f84        67759a80360c   12 hours ago     Up About a minute    MyContainer2
    c1524520d864        67759a80360c   12 hours ago     Up About a minute    MyContainer3
    

    After that you have your containers created forever and you can start and stop them like VMs.

    docker start MyContainer1
    

提交回复
热议问题