首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >docker-compose up将其图像保存在哪里?

docker-compose up将其图像保存在哪里?
EN

Stack Overflow用户
提问于 2018-05-23 18:06:03
回答 2查看 258关注 0票数 0

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

EN

回答 2

Stack Overflow用户

发布于 2018-05-23 18:10:42

您可以传递额外的参数(--no- cache )来跳过在构建过程中使用cache。

代码语言:javascript
复制
    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:~$
票数 1
EN

Stack Overflow用户

发布于 2018-05-23 18:12:52

docker-compose使用图像,您可以使用docker images查看

代码语言:javascript
复制
$ 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_ubuntu镜像。

docker image prune认为这些图像正在使用中,所以它不会删除它们。

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

代码语言:javascript
复制
docker image rm docker_ubuntu
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/50485465

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档