[英]When does docker-compose build a local image and when does it pull from docker hub?
Following the tutorial of docker compose. 遵循docker compose的教程。 Let's say you have a Dockerfile for your app and docker-compose.yml for its services. 假设您有一个用于应用程序的Dockerfile和一个用于服务的docker-compose.yml。
Dockerfile Docker文件
FROM ruby:2.3.3
...
COPY . /myapp
docker-compose.yml docker-compose.yml
version: '3'
services:
db:
image: postgres
web:
build: .
image: dre-hh/myapp
volumes:
- .:/myapp
depends_on:
- db
While developing you would like to build the app from the local filesystem with docker-compose. 在开发过程中,您想使用docker-compose从本地文件系统构建应用程序。 Then later you could upload the app docker image to docker hub. 然后,您可以将应用docker映像上传到docker hub。
Do you need separted overridable configurations if you want to choose between building from local system or from docker hub? 如果要在从本地系统构建还是从Docker Hub构建之间进行选择,是否需要分离的可覆盖配置? Or is it possible somehow else as one can specify both build and image options on the yaml file? 还是有其他可能,因为可以在yaml文件上同时指定build和image选项?
When using build: with image: , the image name is simply to let you choose which name that docker-compose will tag the image as. 在将build:与image:一起使用时 ,映像名称只是为了让您选择docker-compose将映像标记为的名称。 To push images, you should use a different config / build workflow, as lvonet mentioned 要推送图像,您应该使用其他配置/构建工作流程,如lvonet所述
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.