<p><a href="https://github.com/docker/compose/issues/5586#issuecomment-375580132" rel="nofollow noreferrer">@decoomanj on github</a> indicated that <code>scale</code> has to be replaced by <code>deploy</code> in conjunction with <code>replicas</code>. </p>

<p>According to <a href="https://github.com/docker/compose/issues/5586#issuecomment-475250276" rel="nofollow noreferrer">mrampant-nist on github</a> one has to use <code>--compatibility</code> as well.</p>

<p>Let's test this. First of all all docker-compose.yml is needed:</p>

<pre><code>version: '3.3'
services:
    nginx:
      image: nginx
      scale: 6
</code></pre>

<p>and issuing:</p>

<pre><code>docker-compose up
</code></pre>

<p>results in:</p>

<pre><code>ERROR: The Compose file './docker-compose.yml' is invalid because:
Unsupported config option for services.nginx: 'scale'
</code></pre>

<p>Applying @decoomanj's suggestion, i.e. replacing replicas:</p>

<pre><code>version: '3.3'
services:
    nginx:
      image: nginx
      deploy:
        replicas: 6
</code></pre>

<p>results in:</p>

<pre><code>WARNING: Some services (nginx) use the 'deploy' key, which will be ignored. Compose does not support 'deploy' configuration - use `docker stack deploy` to deploy to a swarm.
</code></pre>

<p>Running <code>docker-compose --compatibility up</code> starts 6 services:</p>

<pre><code>CONTAINER ID        IMAGE               COMMAND                  CREATED             STATUS              PORTS               NAMES
f19aa54634d7        nginx               "nginx -g 'daemon of…"   5 seconds ago       Up 4 seconds        80/tcp              6233_nginx_5
749cff4ac1c3        nginx               "nginx -g 'daemon of…"   5 seconds ago       Up 3 seconds        80/tcp              6233_nginx_3
b86ed7b217fe        nginx               "nginx -g 'daemon of…"   5 seconds ago       Up 1 second         80/tcp              6233_nginx_6
0b92e5ef4a0e        nginx               "nginx -g 'daemon of…"   5 seconds ago       Up 2 seconds        80/tcp              6233_nginx_2
e414bca52b53        nginx               "nginx -g 'daemon of…"   5 seconds ago       Up 4 seconds        80/tcp              6233_nginx_4
e9f33dc634a8        nginx               "nginx -g 'daemon of…"   6 seconds ago       Up 5 seconds        80/tcp              6233_nginx_1
</code></pre>

<p>In conclusion, <code>replicas</code> has to be replaced by <code>deploy</code> and <code>replicas</code> and <code>--compatibility</code> is needed to solve the issue. </p>

CC BY-SA 4.0
2019-12-24T18:59:44.123Z
2019-12-24T19:19:39.710Z
2019-12-24T19:19:39.710Z
030
<p>According to docker-compose issue #5586, <a href="https://github.com/docker/compose/issues/5586" rel="noreferrer"><code>scale</code> is deprecated</a>. The replacement is <a href="https://docs.docker.com/compose/compose-file/#deploy" rel="noreferrer"><code>deploy.replicas</code></a> but that latter is not handled by <code>docker-compose</code>, only by <code>docker stack</code> implying you have to run Docker in swarm mode.</p>

<p>As alternate solutions, you can scale services from the command line with docker-compose:</p>

<pre><code>docker-compose up --scale app=3
</code></pre>

<p>I'm not too fond of this solution since in my understanding <code>docker-compose.yml</code> is supposed to be self-contained and should not depend on command line options. </p>

<p>Another option is to run docker-compose in <a href="https://docs.docker.com/compose/compose-file/compose-versioning/#compatibility-mode" rel="noreferrer"><code>--compatibility</code> mode</a>:</p>

<pre><code>docker-compose --compatibility up
</code></pre>

<p>In that case, <code>docker-compose</code> will translate some <code>deploy</code> entries into their <em>version 2</em> equivalent. But because of the name of that option, and because of the warnings in the docs, it does not look like a mid- to long-term solution.</p>

<p>What would you suggest to replace the docker-compose <em>v2</em> <code>scale</code> option?</p>

<docker-compose>
How to create replicas in docker-compose when `scale` is deprecated?
Sylvain Leroux
# How to create replicas in docker-compose when `scale` is deprecated?

(Asked by: username_0 on 2019-02-05)

According to docker-compose issue #5586, scale is deprecated. The replacement is deploy.replicas but that latter is not handled by docker-compose, only by docker stack implying you have to run Docker in swarm mode.
As alternate solutions, you can scale services from the command line with docker-compose:
docker-compose up --scale app=3

I'm not too fond of this solution since in my understanding docker-compose.yml is supposed to be self-contained and should not depend on command line options. 
Another option is to run docker-compose in --compatibility mode:
docker-compose --compatibility up

In that case, docker-compose will translate some deploy entries into their version 2 equivalent. But because of the name of that option, and because of the warnings in the docs, it does not look like a mid- to long-term solution.
What would you suggest to replace the docker-compose v2 scale option?

**Tags:** docker-compose


---

## 1 answers

### Answer by username_1 on 2019-12-24. Score: 3

@decoomanj on github indicated that scale has to be replaced by deploy in conjunction with replicas. 
According to mrampant-nist on github one has to use --compatibility as well.
Let's test this. First of all all docker-compose.yml is needed:
version: '3.3'
services:
    nginx:
      image: nginx
      scale: 6

and issuing:
docker-compose up

results in:
ERROR: The Compose file './docker-compose.yml' is invalid because:
Unsupported config option for services.nginx: 'scale'

Applying @decoomanj's suggestion, i.e. replacing replicas:
version: '3.3'
services:
    nginx:
      image: nginx
      deploy:
        replicas: 6

results in:
WARNING: Some services (nginx) use the 'deploy' key, which will be ignored. Compose does not support 'deploy' configuration - use `docker stack deploy` to deploy to a swarm.

Running docker-compose --compatibility up starts 6 services:
CONTAINER ID        IMAGE               COMMAND                  CREATED             STATUS              PORTS               NAMES
f19aa54634d7        nginx               "nginx -g 'daemon of…"   5 seconds ago       Up 4 seconds        80/tcp              6233_nginx_5
749cff4ac1c3        nginx               "nginx -g 'daemon of…"   5 seconds ago       Up 3 seconds        80/tcp              6233_nginx_3
b86ed7b217fe        nginx               "nginx -g 'daemon of…"   5 seconds ago       Up 1 second         80/tcp              6233_nginx_6
0b92e5ef4a0e        nginx               "nginx -g 'daemon of…"   5 seconds ago       Up 2 seconds        80/tcp              6233_nginx_2
e414bca52b53        nginx               "nginx -g 'daemon of…"   5 seconds ago       Up 4 seconds        80/tcp              6233_nginx_4
e9f33dc634a8        nginx               "nginx -g 'daemon of…"   6 seconds ago       Up 5 seconds        80/tcp              6233_nginx_1

In conclusion, replicas has to be replaced by deploy and replicas and --compatibility is needed to solve the issue.


---

