简体   繁体   English

docker-compose何时构建本地映像,何时从docker hub提取?

[英]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.

相关问题 “docker-compose”似乎不允许或构建本地图像 - “docker-compose” does not appear to allow or build from local images docker-compose 什么时候使用当前构建的镜像,什么时候重新制作本地镜像? - when does docker-compose use currently built images and when does it remake the local image? docker-compose何时调用Dockerfile? - When Does docker-compose call the Dockerfile? `docker-compose logs` 从哪里拉取? - Where does `docker-compose logs` pull from? Docker 容器工作,但从 docker-compose 构建时失败 - Docker container works, but fails when build from docker-compose 为什么 docker-compose 会在 `docker-compose up` 上构建一个新镜像? - Why does docker-compose build a new image on `docker-compose up`? 使用docker-compose build时Docker不创建新容器 - Docker does not create a new container when using docker-compose build docker-compose 是否构建镜像并运行容器? - Does docker-compose build an image and run a container? Docker-compose:为什么重新启动不适用于 docker-compose 运行或 docker-compose 文件中只有一个容器时 - Docker-compose: Why restart does not work with docker-compose run or when there's only one container in docker-compose file 使用docker hub时如何强制docker-compose下载新镜像? - How to force docker-compose to download a new image when using docker hub?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM