我知道如果我更改我的Dockerfile或build目录,我应该运行docker-compose build。这无疑意味着docker-compose在其已构建的镜像中有一些缓存。
它在哪里?我如何清除它?
我想回到这样一种状态,在这种状态下,docker-compose up必须执行初始构建步骤,而不需要我记得运行docker-compose build。
我已经运行了docker stop $(docker ps -aq)和docker X prune (对于容器、映像、卷、网络中的X),但docker-compose up仍然拒绝在我的Dockerfile中运行构建步骤。
或者我完全误解了docker-compose的工作原理?
发布于 2018-05-23 18:10:42
您可以传递额外的参数(--no- cache )来跳过在构建过程中使用cache。
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:~$发布于 2018-05-23 18:12:52
docker-compose使用图像,您可以使用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 264MBdocker-compose图像的前缀通常是运行docker-compose的目录的名称。所以,对我来说,docker_ubuntu镜像。
docker image prune认为这些图像正在使用中,所以它不会删除它们。
要删除docker-compose图像,您需要显式删除它:
docker image rm docker_ubuntuhttps://stackoverflow.com/questions/50485465
复制相似问题