首页 > 解决方案 > docker-compose up 在哪里保存它的图像?

问题描述

我知道如果我更改我的Dockerfile或构建目录,我应该运行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 的工作原理?

标签: docker-compose

解决方案


您可以传递其他参数(--no-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:~$

推荐阅读