I thought it was already there.
$ docker-compose build --help
Build or rebuild services.
Services are built once and then tagged as `project_service`,
e.g. `composetest_db`. If you change a service's `Dockerfile` or the
contents of its build directory, you can run `docker-compose build` to rebuild it.
Usage: build [options] [SERVICE...]
Options:
--force-rm Always remove intermediate containers.
--no-cache Do not use cache when building the image.
--pull Always attempt to pull a newer version of the image.
@shin- I thought this was asking to add a no-cache option directly in the Compose file. Something like:
build:
context: .
options:
- no-cache
In this way when you run docker-compose build, it already knows where to use the cache.
As of today, if you want to build 2 images specified in the same Compose file, one using the cache and the other without, you have to run 2 separate commands.
Anyway a general options for build in the Compose file would allow several improvements over time. Like the future squash option (experimental in Docker 1.13), the compress option (available in Docker 1.13), the cache-from option (Docker 1.13 too), etc.
This option is nice.
Agree with @philtay question about no-cache/cache per service more meaningful at this time. Is this possible now?
Most helpful comment
@shin- I thought this was asking to add a
no-cacheoption directly in the Compose file. Something like:In this way when you run
docker-compose build, it already knows where to use the cache.As of today, if you want to build 2 images specified in the same Compose file, one using the cache and the other without, you have to run 2 separate commands.
Anyway a general
optionsforbuildin the Compose file would allow several improvements over time. Like the futuresquashoption (experimental in Docker 1.13), thecompressoption (available in Docker 1.13), thecache-fromoption (Docker 1.13 too), etc.