Compose: docker-compose.yml ignores "scale:" option for version 3

Created on 18 Jan 2018  路  15Comments  路  Source: docker/compose

This works:

version: '2.2'
services:
    template:
      image: tutum/hello-world
      scale: 2

This doesn't work

version: '3'
services:
    template:
      image: tutum/hello-world
      scale: 2

but I didn't find any documentation about it on https://docs.docker.com/compose/compose-file/compose-versioning/#version-3

Most helpful comment

For people looking for a quick migration:

  1. Update your version to 3+
  2. Replace scale by
deploy:
 replicas: 3

  1. Run docker-compose --compatibility ...

Hope this helps :-)

All 15 comments

@beephotography
The scale is deprecated you can find the details here

You can use: docker-compose up --scale template=2

scale was never added to v3, as it already has deploy.replicas.

The documentation states

This only takes effect when deploying to a swarm with docker stack deploy, and is ignored by docker-compose up and docker-compose run.

It's a shame it's missing in v3. Now we have to update all our up calls? I'm using this a lot with docker-compose only, no swarm or w/e.

The migration guide should be updated accordingly. There's no hint that scale was removed!

ref #5589

Thank you for clarification, @ghsatpute but @spiderpug is right, there's no hint that scale was removed.

Furthermore, if I follow the up link to https://docs.docker.com/compose/reference/up/ I can find the following description for --scale:

    --scale SERVICE=NUM        Scale SERVICE to NUM instances. Overrides the `scale`
                               setting in the Compose file if present.

Thus, I would understand that setting scale in the compose file is still possible!

In v2 I've used "scale" to scale up some services during the start of my development setup. I'm not interested in using Swarm for that. What is the recommended way to get this behaviour back? I don't want to fall back to defining one service three times or use the CLI to scale. It would be a shame when this doesn't work anymore.

Ok, I'll give the compatibility mode a try. Thanks for the hint @shin- !

For people looking for a quick migration:

  1. Update your version to 3+
  2. Replace scale by
deploy:
 replicas: 3

  1. Run docker-compose --compatibility ...

Hope this helps :-)

Unfortunately this doesn't seem to work with:

deploy: 
  replicas: 0

Me too @Cirilo17 .

It doesn't work for me neither.

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

Here's my docker-compose.yml file

version: '3'
services:
  demo:
    build:
      context: ./
      dockerfile: Dockerfile-build
    image: demoweb
    ports:
      - 8080
    networks:
      - network1
#    deploy:
#      replicas: 3
#      mode: replicated

networks:
  network1:

@hendisantika as @decoomanj mentioned, it does work, you just have to use the --compatibility flag when using docker-compose:
i.e. in your case docker-compose --compatibility up -d

Ooo... ya. It's working now with that command.
Thank You @mrampant-nist

--compatibility is awesome, thanks to the devs who put it in and the helpful folks who outlined its usage here.

It seems like deploy.replicas: 0 no longer works with version 1.27.0: #7735

@Leland-Takamine isnt there a better way to disable a service?

Was this page helpful?
0 / 5 - 0 ratings