Reputation: 91875
I'm aware that if I change my Dockerfile
or build directory, I'm supposed to run docker-compose build
. This surely implies that docker-compose has some cache somewhere of its already-built images.
Where is it? How do I purge it?
I'd like to get back to a state where docker-compose up
is forced to do the initial build steps, without me needing to remember to run docker-compose build
.
I've run docker stop $(docker ps -aq)
and docker X prune
(for X in container, image, volume, network), but docker-compose up
still refuses to run the build steps in my Dockerfile
.
Or am I completely misunderstanding how docker-compose works?
Upvotes: 0
Views: 553
Reputation: 91875
docker-compose uses images, which you can see with docker images
:
$ docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
docker_ubuntu latest a7dc4f9bbdfb 19 hours ago 158MB
ubuntu 16.04 0b1edfbffd27 3 weeks ago 113MB
hello-world latest f2a91732366c 6 months ago 264MB
The docker-compose images are prefixed with (usually) the name of the directory you're running docker-compose
in. So, for me, the docker_ubuntu
image.
docker image prune
thinks that the images are in use, so it doesn't prune them.
To get rid of the docker-compose image, you need to delete it explicitly:
docker image rm docker_ubuntu
Upvotes: 0
Reputation: 2477
you can pass on additional argument (--no-cache) to skip using cache during build process.
docker@default:~$ 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] [--build-arg key=val...] [SERVICE...]
Options:
--compress Compress the build context using gzip.
--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.
-m, --memory MEM Sets memory limit for the build container.
--build-arg key=val Set build-time variables for services.
docker@default:~$
Upvotes: 1