Compose: Possibility to use --no-cache for a single service

Created on 23 Sep 2016  路  4Comments  路  Source: docker/compose

Actually , we can use the instruction docker-compose build --no-cache to avoid using the cache.

For instance , if we have the following docker-compose file

version: '2'
services:
  service1:
    build:
      context: .
    container_name: service1_cont_name
  service2:
    build:
      context: .
    container_name: service2_cont_name

If we need to apply --no-cache only for service1 , it will be usefull to have an option in the build instruction to define this kind of action.

Most helpful comment

So , I think It would be more understandable to avoid running two commands for this kind of purpose. Why not adding a specific option in the build instruction, something like

version: '2'
services:
  service1:
    build:
      context: .
      cache: false
    container_name: service1_cont_name
  service2:
    build:
      context: .
    container_name: service2_cont_name

Assuming the default value of cache is true . I think it would make more sense for the docker-compose file.

All 4 comments

Hi!

You can already do this through docker-compose build --no-cache service1. I'm not sure I agree that no-cache should be part of the configuration.

Hi @shin- ,

docker-compose build --no-cache service1
will only build service1 .
But assuming that I have a lot of services defined in my docker-compose file , this command won't be enough.
So the workaround would be to identify the service that required the no-cache option and rebuild all the services ?

Kind of

docker-compose build --no-cache service1 && docker-compose build

Yes, that would be the way to go about it.

So , I think It would be more understandable to avoid running two commands for this kind of purpose. Why not adding a specific option in the build instruction, something like

version: '2'
services:
  service1:
    build:
      context: .
      cache: false
    container_name: service1_cont_name
  service2:
    build:
      context: .
    container_name: service2_cont_name

Assuming the default value of cache is true . I think it would make more sense for the docker-compose file.

Was this page helpful?
0 / 5 - 0 ratings