compose build.context.additional_contexts should support another service image as the base image

未关闭
#4,280 0 条评论 1 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 3 天内回复

还没有人认领这个 Issue。

评估

难度
4/5
预计耗时
3-5 天
新手友好度
45/100
Issue 类型
缺陷
描述清晰度
基本清楚
活跃度
停滞
技术栈
docker-compose, go
领域
build-system, cli

调研方向

从 nerdctl compose build 路径及其对 build.additional_contexts 的处理入手,使用所提供的 service:base 示例作为复现。将其解析方式与 Docker Compose 文档所述的依赖镜像行为进行比较,并验证依赖的 base 镜像可以作为 base_image 使用,而不会出现所示的本地路径错误。

由索引模型根据 Issue 内容生成。

描述

kind/feature
What is the problem you're trying to solve

See https://docs.docker.com/compose/how-tos/dependent-images/#use-another-services-image-as-the-base-image

I tried following example

services:
 base:
  image: base
  build:
    context: .
    dockerfile: Base.containerfile
 my-service:
  image: base
  build:  
    context: .
    dockerfile: Service1.containerfile
    additional_contexts:
      base_image: service:base
[root@nginxunitlia test]# nerdctl compose build 
INFO[0000] Building image base                          
[+] Building 2.8s (5/5) FINISHED                                                                                                                     
 => [internal] load build definition from Base.containerfile                                                                                    0.0s
 => => transferring dockerfile: 121B                                                                                                            0.0s
 => [internal] load metadata for docker.io/library/almalinux:9                                                                                  1.7s
 => [internal] load .dockerignore                                                                                                               0.0s
 => => transferring context: 2B                                                                                                                 0.0s
 => [1/1] FROM docker.io/library/almalinux:9@sha256:e781633da358ff79d6ad69a080cfacbff5edd7f66473bcbd31105d1f2d977e5b                            0.5s
 => => resolve docker.io/library/almalinux:9@sha256:e781633da358ff79d6ad69a080cfacbff5edd7f66473bcbd31105d1f2d977e5b                            0.0s
 => => sha256:0f8a51a00283c0f5f6a29f00f346ec8ff4bc9349b54a5531d64e5065c576ac21 69.77MB / 69.77MB                                                0.5s
 => exporting to docker image format                                                                                                            1.0s
 => => exporting layers                                                                                                                         0.0s
 => => exporting manifest sha256:e639a26a3199572d52498eb335e06e2da97499ef72c586bc3b9dc6e7f0be262f                                               0.0s
 => => exporting config sha256:ffbfe0e93c2675800088cc4ee24e58c71f9173a9df8dca942cd3977cf0739e69                                                 0.0s
 => => sending tarball                                                                                                                          0.5s
unpacking docker.io/library/base:latest (sha256:e639a26a3199572d52498eb335e06e2da97499ef72c586bc3b9dc6e7f0be262f)...
Loaded image: docker.io/library/base:latest
INFO[0005] Building image base                          
error: invalid local: resolve : lstat /root/containers/test/service:base: no such file or directory
FATA[0000] no image was built                           
FATA[0005] error while building image base: exit status 1 
Describe the solution you'd like

To work like docker compose

Additional context
[root@nginxunitlia test]# nerdctl --version
nerdctl version 2.1.2
主要语言
Go
星标
10.5k
派生
853
平均合并
6 天 14 小时
30 天内合并 PR
38

环境准备

  • 提供 Dockerfile 或 Docker Compose 文件
  • 没有 Pull Request 模板
  • 没有贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

containerd/nerdctl 的其他 Issue

查看 containerd/nerdctl 的全部 Issue

相似的 Issue

更多 Go Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。