[英]docker-compose.yml override remove build for image
I have:我有:
docker-compose.yml
: docker-compose.yml
:
services:
app:
build: .
and docker-compose.override.yml
:和
docker-compose.override.yml
:
services:
app:
image: my_repo/my_app:my_tag
When I do docker-compose up
, it actually does build: .
当我做
docker-compose up
,它实际上是build: .
instead of using the overriden image: my_repo/my_app:my_tag
.而不是使用覆盖的
image: my_repo/my_app:my_tag
。
I guess I should go for some kind of build: false
or build: none
to make sure it reads the image
attribute, shouldn't I?我想我应该 go 用于某种
build: false
或build: none
以确保它读取image
属性,不是吗? Since override seems to act like a merge, it would result as if both entries were there:由于覆盖似乎像合并一样,因此会导致两个条目都在那里:
services:
app:
build: .
image: my_repo/my_app:my_tag
and it seems like build
is prioritary to image
(from the docs ).并且似乎
build
优先于image
(来自文档)。
I believe the correct way to do it is to have a base docker-compose.yml
like:我相信正确的方法是拥有一个基础
docker-compose.yml
,例如:
services:
app:
image: my_repo/my_app:my_tag
and the docker-compose.override.yml
:和
docker-compose.override.yml
:
services:
app:
build: .
This way when you launch docker-compose up
the image will be built with build context .
这样,当您启动
docker-compose up
,将使用 build context 构建图像.
Another example with docker-compose.override.yml
with different image:另一个带有不同图像的
docker-compose.override.yml
示例:
services:
app:
image : my_repo/other_image:tag
And here the image from docker-compose.override.yml
will take precedence.在这里,来自
docker-compose.override.yml
的图像将优先。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.