docker-compose.override.yml target is not overwrite on mac
Description
Using a Mac M1 with docker desktop for mac, version 4.8.1. Tested with all experimental features disabled and enabled, buildkit included
docker-compose targets are not being overwritten when using docker-compose.override.yml
Steps to reproduce the issue:
- Create a docker-compose.yml and a docker-compose.override.yml (I'm using https://github.com/dunglas/symfony-docker)
- Run
docker-compose -f docker-compose.yml -f docker-compose.override.yml build --pull --no-cache
Describe the results you received: Only docker-compose.yml environment variables and volumes seems to be overwriten, target is not, so my Dockerfile is not built properly
Describe the results you expected: Docker-compose uses docker-compose.override.yml and overrides target
Additional information you deem important (e.g. issue happens only occasionally):
Output of docker compose version:
Docker Compose version 2.5.0
Output of docker info:
Client:
Context: default
Debug Mode: false
Plugins:
buildx: Docker Buildx (Docker Inc., v0.8.2)
compose: Docker Compose (Docker Inc., v2.5.0)
sbom: View the packaged-based Software Bill Of Materials (SBOM) for an image (Anchore Inc., 0.6.0)
scan: Docker Scan (Docker Inc., v0.17.0)
Server:
Containers: 126
Running: 2
Paused: 0
Stopped: 124
Images: 181
Server Version: 20.10.14
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: 3df54a852345ae127d1fa3092b95168e4a88e2f8
runc version: v1.0.3-0-gf46b6ba
init version: de40ad0
Security Options:
seccomp
Profile: default
cgroupns
Kernel Version: 5.10.104-linuxkit
Operating System: Docker Desktop
OSType: linux
Architecture: aarch64
CPUs: 4
Total Memory: 7.667GiB
Name: docker-desktop
ID: KAG6:727Z:BY5I:5YS3:C24I:235U:P4EV:ZUIL:C72U:ZGQ3:OLGP:QAYX
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:5000
127.0.0.0/8
Live Restore Enabled: false
Additional environment details:
@alejgarciarodriguez
docker-compose use v1 of compose, not v2.
Are you able to try out the following minimal example ? Everything works as expected on my end so I'm suspecting compose v1 or your compose files.
Dockerfile
FROM alpine:latest as prod
CMD echo prod
FROM alpine:latest as dev
CMD echo dev
compose.yaml
version: '3'
services:
app:
build:
context: .
target: dev
compose.override.yaml
version: '3'
services:
app:
build:
context: .
target: prod
Testing
docker compose -f compose.yaml up --build
[+] Running 1/0
⠿ Container test-compose-9479-app-1 Created 0.0s
Attaching to test-compose-9479-app-1
test-compose-9479-app-1 | dev
test-compose-9479-app-1 exited with code 0
docker compose -f compose.yaml -f compose.override.yaml up --build
[+] Running 1/1
⠿ Container test-compose-9479-app-1 Recreated 0.0s
Attaching to test-compose-9479-app-1
test-compose-9479-app-1 | prod
test-compose-9479-app-1 exited with code 0
I tried your example and its working just fine, as expected.
I didn't know I can use docker compose instead of docker-compose.
docker compose version is 2.5.1 and docker-compose version is 2.5.0 by the way
Updated today to docker-for-mac 4.8.2. Now its working. Probably the error was in my makefiles and dockerfiles I think, after some refactor now its working.
Thank you @maxcleme , no issue so far, so we can close this