nerdctl
nerdctl copied to clipboard
compose build.context.additional_contexts should support another service image as the base image
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