【发布时间】:2021-01-30 01:00:46
【问题描述】:
我有一个设置,我正在从一组 shell 脚本迁移到 docker-compose。我要构建的容器使用由自定义 dockerfile 创建的父容器。但我看不到如何让 docker-compose (重新)构建必要的父容器。
一共有三个文件:
/code/containers/parent/DockerFile
FROM centos:7
RUN... (rest of file to create common stuff used by multiple child images)
/code/containers/child-one/Dockerfile
FROM parent
RUN...
/code/docker-compose.yml
version: '3.3'
services:
my-service:
image: child-one
build:
dockerfile: containers/child-one/Dockerfile
context: .
正如预期的那样,它会失败:
服务“我的服务”构建失败:找不到存储库父级:不存在或没有拉取访问权限
除了手动运行 docker 先构建父镜像之外,找不到任何解决方案。
非常感谢任何想法。
编辑:基于 VonCs 的想法:
version: '3.3'
services:
parent-notservice;
image: parent
build:
dockerfile: containers/parent/Dockerfile
context: .
my-service:
image: child-one
depends_on:
parent
build:
dockerfile: containers/child-one/Dockerfile
context: .
但是我不得不使用depends_on,这是一个hack,我担心父母开始的影响(当孩子跑步时)。这不是我的意图。
【问题讨论】:
标签: docker docker-compose dockerfile