您可以通过指定项目名称(默认为目录名称)来重新使用docker compose模板:
$ docker-compose --project-name inst1 up -d Creating inst1_web_1 $ docker-compose --project-name inst2 up -d Creating inst2_web_1
您还可以扩大项目中的容器实例:
$ docker-compose --project-name inst2 scale web=5 Creating and starting 2 ... done Creating and starting 3 ... done Creating and starting 4 ... done Creating and starting 5 ... done
现在应该有6个容器在运行:
$ docker ps CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES 5e4ab4cebacf tomcat:8.0 "catalina.sh run" 43 seconds ago Up 42 seconds 0.0.0.0:32772->8080/tcp inst2_web_2 ced61f9ac2db tomcat:8.0 "catalina.sh run" 43 seconds ago Up 42 seconds 0.0.0.0:32773->8080/tcp inst2_web_5 efb1ef13147c tomcat:8.0 "catalina.sh run" 43 seconds ago Up 42 seconds 0.0.0.0:32771->8080/tcp inst2_web_4 58e524da3473 tomcat:8.0 "catalina.sh run" 43 seconds ago Up 42 seconds 0.0.0.0:32770->8080/tcp inst2_web_3 0f58c3c3b0ed tomcat:8.0 "catalina.sh run" 2 minutes ago Up 2 minutes 0.0.0.0:32769->8080/tcp inst2_web_1 377e3e5b03e4 tomcat:8.0 "catalina.sh run" 2 minutes ago Up 2 minutes 0.0.0.0:32768->8080/tcp inst1_web_1