大网数据广告活动
服务器运维问答

docker-compose scale command does not work

· 52CE 我爱测

When I enter the command docker-compose up -d --scale web=5 The following is displayed Builds, (re)creates, starts, and attaches to containers for a service. Unless they are already running, this command also starts any linked se…

问题原文

原帖链接 · garrymd · CC BY-SA 4.0

When I enter the command

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

The following is displayed

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.

No service is scaled up.

The OS is openSUSE Leap.

The remainder of the output is

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

The version of docker-compose is 1.8.1.

The docker-compose.yml file is

    version: '2'

    services:

            web:
               image: nginx:alpine

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

已采纳解答

原帖链接 · BMitch · CC BY-SA 4.0

The --scale flag was not introduced until the 1.13.0 release in May 2017. The 1.8.1 release is rather outdated (from September 2016) and should be upgraded.

You can pull the latest release from the docker-compose github releases page.

摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。

资料来源与适用范围

资料来源
Server Fault
适用范围
以原帖系统、软件版本与发布日期为准(2019-11-07)
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 4.0

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。