Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Remove service on docker-compose through overriding

I want to remove a container defined in docker-compose.yml file when we run in composition/override with another file docker-compose.prod.yml, by example:

# docker-compose.yml
version: 2
services: 

  www:
    image: php56

  db_for_development:
    image: mariadb

override with:

# docker-compose.prod.yml
version: 2
services: 

  www:
    image: php70

  db_for_development:
    [control: override-and-remove] # hypothesis

Then, when running:

docker-compose -f docker-compose.yml -f docker-compose.prod.yml up -d
docker-compose -f docker-compose.yml -f docker-compose.prod.yml ps

Actually, i have www and db_for_development together.

I want only www container, not others.

like image 281
Francesco Bianco Avatar asked Dec 08 '17 16:12

Francesco Bianco


1 Answers

You may have to switch to version: 3 to do this, I believe on version: 2 you can use the "scale" parameter but I'm not 100% sure.

Anyways, you can override the "replicas" parameter like this:

# docker-compose.prod.yml
version: "3"
services: 

  db_for_development:
    deploy:
      replicas: 0
like image 178
Matt Blaha Avatar answered Oct 21 '22 11:10

Matt Blaha