You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
➜ knowledge git:(master) docker-compose scale --help
Set number of containers to run for a service.
Numbers are specified in the form `service=num` as arguments.
For example:
$ docker-compose scale web=2 worker=3
This command is deprecated. Use the up command with the `--scale` flag
instead.
Usage: scale [options] [SERVICE=NUM...]
Options:
-t, --timeout TIMEOUT Specify a shutdown timeout in seconds.
(default: 10)
简单总结一下也就是制定容器运行的个数,比如有一个 web 服务,你可以指定运行个数,比如 5 个。
docker-compose scale 也有一些小坑
在 docker-compose service 中,不能指定 name,不然扩容的时候会报错,说容器名字已存在。
➜ knowledge git:(master) docker-compose scale web=3
WARNING: The scale command is deprecated. Use the up command with the --scale flag instead.
Starting knowledge_web_1 ... done
Creating knowledge_web_2 ... done
Creating knowledge_web_3 ... done
某天心血来潮,
docker-compose --help
想看下docker-compose
有哪些自己没发现好玩的命令。然后就发现了
docker-compose scale
,使用方式如下简单总结一下也就是制定容器运行的个数,比如有一个 web 服务,你可以指定运行个数,比如
5
个。下面以我 Github 某个项目的 docker-compose 举例
Nginx 指定映射端口 8080,反向代理 web。
docker-compose scale
扩容 web当然了也可以扩容 mysql / redis / elasticsearch(需要配置
启动多个个 web 服务
这里提示命令已经过时,那我们换一个命令
这样子的就创建了 web 服务,nginx 容器配置一个
proxy_pass
即可。请求会通过 nginx 转发到不同的 web。
The text was updated successfully, but these errors were encountered: