-
Notifications
You must be signed in to change notification settings - Fork 5.8k
Description
Description
When using additional_contexts as per #10369, it is possible to use a relative path. It appears that the relative path is interpreted differently than the path specified in context.
The actual behavior is that the path is interpreted as relative to the current directory.
The expected behavior is that the path be interpreted as relative to the compose file that contains it, as is the behavior of thecontext field.
It is possible that the current directory is not that of the compose file. For example, when using docker compose -f <path-to-compose-file>. Another example is when using extends field in a service definition; if an additional context path is defined in the base, then the path should be interpreted as relative to the base.
Steps To Reproduce
- Create a compose file with a service definition that includes an
additional_contextsblock with a relative path. - Create a Dockerfile that uses the additional context in a
FROMstatement. - Verify that
docker compose buildworks as expected. - Change the current directory, run
docker compose -f <path-to-compose-file> build, and verify that it doesn't work as expected.
Compose Version
Docker Compose version v2.17.2
Docker Compose version v2.17.2
Docker Environment
Client:
Context: default
Debug Mode: false
Plugins:
buildx: Docker Buildx (Docker Inc., v0.10.4)
compose: Docker Compose (Docker Inc., v2.17.2)
dev: Docker Dev Environments (Docker Inc., v0.1.0)
extension: Manages Docker extensions (Docker Inc., v0.2.19)
init: Creates Docker-related starter files for your project (Docker Inc., v0.1.0-beta.2)
sbom: View the packaged-based Software Bill Of Materials (SBOM) for an image (Anchore Inc., 0.6.0)
scan: Docker Scan (Docker Inc., v0.25.0)
scout: Command line tool for Docker Scout (Docker Inc., v0.9.0)
Server:
Containers: 124
Running: 56
Paused: 0
Stopped: 68
Images: 298
Server Version: 20.10.24
Storage Driver: overlay2
Backing Filesystem: extfs
Supports d_type: true
Native Overlay Diff: true
userxattr: false
Logging Driver: json-file
Cgroup Driver: cgroupfs
Cgroup Version: 2
Plugins:
Volume: local
Network: bridge host ipvlan macvlan null overlay
Log: awslogs fluentd gcplogs gelf journald json-file local logentries splunk syslog
Swarm: inactive
Runtimes: io.containerd.runc.v2 io.containerd.runtime.v1.linux runc
Default Runtime: runc
Init Binary: docker-init
containerd version: 2456e983eb9e37e47538f59ea18f2043c9a73640
runc version: v1.1.4-0-g5fd4c4d
init version: de40ad0
Security Options:
seccomp
Profile: default
cgroupns
Kernel Version: 5.15.49-linuxkit
Operating System: Docker Desktop
OSType: linux
Architecture: x86_64
CPUs: 8
Total Memory: 16.1GiB
Name: docker-desktop
ID: DHKG:6GF4:HAHF:NE6Y:W3PD:D4CX:WM4I:UVDH:T4ZB:HBHV:5QIE:FHJ2
Docker Root Dir: /var/lib/docker
Debug Mode: false
HTTP Proxy: http.docker.internal:3128
HTTPS Proxy: http.docker.internal:3128
No Proxy: hubproxy.docker.internal
Registry: https://index.docker.io/v1/
Labels:
Experimental: false
Insecure Registries:
hubproxy.docker.internal:5555
127.0.0.0/8
Live Restore Enabled: false
Anything else?
No response