我尝试从
docker-compose up -d
两个 docker 容器开始,但它只启动一个,我还需要启动其他容器。有什么方法可以在本地主机中做到这一点,或者如果我可以在其他端口上启动,该怎么做?
第一个项目 nginx:
nginx:
image: nginx:alpine
volumes:
- ${APP_PATH_HOST:-./}:/var/www/html
- .docker/nginx/default:/etc/nginx/conf.d/default.conf
- ./localhost.crt:/etc/ssl/certs/localhost.crt
- ./localhost.key:/etc/ssl/private/localhost.key
ports:
- "${HOST_HTTP_PORT:-80}:80"
- "443:443"
depends_on:
- php-fpm
networks:
- app-network
第二个项目:
nginx:
image: nginx:alpine
volumes:
- ${APP_PATH_HOST:-./}:/var/www/html
- .docker/nginx/default:/etc/nginx/conf.d/default.conf
- ./localhost.crt:/etc/ssl/certs/localhost.crt
- ./localhost.key:/etc/ssl/private/localhost.key
ports:
- "${HOST_HTTP_PORT:-8080}:80"
- "4430:443"
- "2022:2022"
depends_on:
- laraphp-fpm
networks:
- proxynet
这个问题是这个问题
的重复您需要在 docker-compose 文件的
replicas
部分中添加 deploy
部分。
对你来说,它会给:
services:
myapp:
image: nginx:latest
deploy:
mode: replicated
replicas: 2
在 docker-compose 文件中添加
replicas
功能之前,我们使用 --scale <my-service>=x
和 x
所需的副本数量 <my-service>
在你的情况下它会给出什么:
services:
myapp:
image: nginx:latest
您可以使用以下命令调用 docker-compose:
docker-compose up -d --scale myapp=2
docker 和 docker-compose 文档完整且制作精良。因此,您要查找的文档中的部分:here