docker-compose scale 命令不起作用

docker-compose scale 命令不起作用

当我输入命令时

docker-compose up -d  --scale web=5 

显示以下内容

Builds, (re)creates, starts, and attaches to containers for a service.

Unless they are already running, this command also starts any linked services.

The `docker-compose up` command aggregates the output of each container. When
the command exits, all containers are stopped. Running `docker-compose up -d`
starts the containers in the background and leaves them running.

没有任何服务得到扩大。

操作系统是 openSUSE Leap。

输出的其余部分是

If there are existing containers for a service, and the service's configuration
or image was changed after the container's creation, `docker-compose up` picks
up the changes by stopping and recreating the containers (preserving mounted
volumes). To prevent Compose from picking up changes, use the `--no-recreate`
flag.

If you want to force Compose to stop and recreate all containers, use the
`--force-recreate` flag.

Usage: up [options] [SERVICE . . . ]

Options:
    -d                              Detached mode: Run containers in the background,
                                    print new container names.
                                    Incompatible with --abort-on-container-exit.
    --no-color                  Produce monochrome output.
    --no-deps                   Don't start linked services.
    --force-recreate            Recreate containers even if their configuration
                                    and image haven't changed.
                                    Incompatible with --no-recreate.
    --no-recreate               If containers already exist, don't recreate them.
                                    Incompatible with --force-recreate.
    --no-build                  Don't build an image, even if it's missing.
    --build                         Build images before starting containers.
    --abort-on-container-exit   Stops all containers if any container was stopped.
                                    Incompatible with -d.
    -t, --timeout TIMEOUT       Use this timeout in seconds for container shutdown
                                    when attached or when containers are already
                                    running. (default: 10)
    --remove-orphans            Remove containers for services not
                                    defined in the Compose file

docker-compose的版本是1.8.1。

docker-compose.yml 文件是

    version: '2'

    services:

            web:
               image: nginx:alpine

            util:
               image: sixeyed/ubuntu-with-utils
               container_name: util
               command: ping web

答案1

直到--scale1.13.0 版本2017 年 5 月。1.8.1 版本相当过时(来自2016 年 9 月) 并应升级。

您可以从docker-compose github 发布页面

答案2

--scale标志仅在新版本中有效。检查 docker-compose 版本:

$ docker-compose -v

如果版本低于 1.24.0,请安装新版本。请按照以下步骤操作:如何升级 docker-compose 到最新版本

相关内容