使用多阶段泊坞窗文件输出多个图像

问题描述 投票:10回答:1

新的docker功能是在dockerfile中执行类似的操作

FROM php7-fpm as build
...

FROM build AS test
...

FROM test AS staging
...

据我所知,最后一个FROM语句标记了最终的输出图像。如何从一个中间图像中获得两个最终图像?

喜欢

...
FROM build AS test
...
FROM test AS staging
...
FROM test AS prod

不应丢弃测试,分期和产品。我想将它们签入存储库。

docker docker-compose docker-multi-stage-build
1个回答
10
投票

您可以在特定阶段停止构建并根据需要标记它们。

docker build --target test -t starx/test:latest .
docker build --target staging -t starx/staging:latest .
docker build --target prod -t starx/prod:latest .

这样,您可以使用不同的图像,并且可以单独按下每个图像。

© www.soinside.com 2019 - 2024. All rights reserved.