Docker compose docker compose up的图像保存在哪里?

Docker compose docker compose up的图像保存在哪里?,docker-compose,Docker Compose,我知道如果我更改了Dockerfile或build目录,我应该运行docker compose build。这无疑意味着docker compose在其已构建的图像的某个地方有一些缓存 它在哪里?我如何清除它 我想回到一个状态,docker compose up被强制执行初始构建步骤,而无需记得运行docker compose build 我已经运行了docker stop$(docker ps-aq)和docker X prune(用于容器、图像、卷、网络中的X),但是docker compo

我知道如果我更改了
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的工作原理?

您可以传递额外的参数(--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:~$

docker compose使用图像,您可以通过
docker图像看到这些图像:

$ 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
docker compose图像的前缀(通常)是您在中运行的目录名
docker compose
。所以,对我来说,
docker\u ubuntu
image

docker image prune
认为这些图像正在使用中,因此不会对其进行修剪

要删除docker compose图像,您需要显式删除它:

docker image rm docker_ubuntu

我根本不想运行
docker compose build
。我想将docker环境重置为强制
docker compose up
重建图像的点。在这种情况下,请尝试
docker compose up--build