docker compose 中“image"和“build"之间的区别 [英] Difference between 'image' and 'build' within docker compose
本文介绍了docker compose 中“image"和“build"之间的区别的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
请帮助我理解 docker compose 中image"和build"之间的区别
Please help me understand the difference between 'image' and 'build' within docker compose
推荐答案
image
表示dockercompose
将基于该图像运行一个容器- build 表示
docker compose
将首先根据与构建关联的路径中找到的 Dockerfile 构建映像(然后基于该映像运行容器). image
meansdocker compose
will run a container based on that image- build means
docker compose
will first build an image based on the Dockerfile found in the path associated with build (and then run a container based on that image).
PR 2458 最终被合并以允许两者(并使用 image
作为构建时的图像名称(如果存在).
PR 2458 was eventually merged to allow both (and use image
as the image name when building, if it exists).
therobyouknow
提到 在评论中:
dockerfile:
作为 build:
下的子语句,可用于指定 Dockerfile 的文件名/路径.
dockerfile:
as a sub-statement beneathbuild:
can be used to specify the filename/path of the Dockerfile.
version: '3'
services:
webapp:
build:
context: ./dir
dockerfile: Dockerfile-alternate
args:
buildno: 1
这篇关于docker compose 中“image"和“build"之间的区别的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文