Prevent service image download from docker-compose.override file

Viewed 36

I have a 'vanilla' docker-compose.yml file for my platform that I'd like to keep without modifying, and I want to make any updates for my solution to my docker-compose.override.yml file.

However there is a service in the docker-compose.yml file that I don't need (and I appropriately set scale:0 for it in the docker-compose.override.yml file, so it's not started upon docker-compose up).

This works, and my service is not started, however the build phase of docker-compose up still sees the service defined, and downloads it's image even though I won't use it.

Is there a way to prevent this image from downloading in the docker-compose build phase, by setting it in docker-compose.override.yml? (Because I don't want to modify docker-compose at all).

Thanks

1 Answers

Not sure it's possible to completely remove a service in your override file but you can change the image to be basic alpine so the build/download phase is minimal. Using restart: "no" also ensures the "removed" service doesn't try to restart

docker-compose.override.yml

services:
  service_to_remove:
    image: alpine:latest
    restart: "no" 

Ideally though, you should only have services required in every environment in your main docker-compose.yml and your overriding config files adding or modifying services

Related