繁体   English   中英

docker-compose,无需启动容器即可重建映像

[英]docker-compose, rebuild image(s) without starting containers

我泊坞窗组成,可以如下定义上下文

version: '3'
services:
    node1:
            build: node1
            image: node1
            container_name: node1

    node2:
            build: node2
            image: node2
            container_name: node2

其中build是指包含Dockerfile和构建资源的目录。 通过使用命令docker-compose up -d --build可以重建映像并重新启动更改的容器。 但是使用下面的docker-compose文件,是否可以仅构建映像而不启动它们,并且最好选择要构建或全部构建的映像?

您可以构建特定的服务而无需像这样启动它们:

docker-compose build node1

要构建它们:

docker-compose build

您也可以尝试docker-compose up --no-start
它将执行构建,创建网络,创建卷而不启动容器。

Usage: up [options] [--scale SERVICE=NUM...] [SERVICE...]

Options:
    -d, --detach               Detached mode: Run containers in the background,
                               print new container names. Incompatible with
                               --abort-on-container-exit.
    --no-color                 Produce monochrome output.
    --quiet-pull               Pull without printing progress information
    --no-deps                  Don't start linked services.
    --force-recreate           Recreate containers even if their configuration
                               and image haven't changed.
    --always-recreate-deps     Recreate dependent containers.
                               Incompatible with --no-recreate.
    --no-recreate              If containers already exist, don't recreate
                               them. Incompatible with --force-recreate and -V.
    --no-build                 Don't build an image, even if it's missing.
    --no-start                 Don't start the services after creating them.

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM