Navigation Menu

Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] DOCKER_DEFAULT_PLATFORM environment variable not working #10041

Closed
jensschulze opened this issue Dec 3, 2022 · 4 comments · Fixed by #10099
Closed

[BUG] DOCKER_DEFAULT_PLATFORM environment variable not working #10041

jensschulze opened this issue Dec 3, 2022 · 4 comments · Fixed by #10099

Comments

@jensschulze
Copy link

jensschulze commented Dec 3, 2022

Description

I am having platform issues on a M1 MacBook pro: Docker Compose v2.13.0 (which comes bundled with Docker Desktop 4.15.0) seems to ignore the environment variable DOCKER_DEFAULT_PLATFORM.

Environment

  • Apple MacBook pro (14", 2021), M1, 32 GByte, macOS Monterey 12.6.1
  • Docker Desktop 4.15.0

docker pull

no platform specified

$ docker pull mysql:5.7
5.7: Pulling from library/mysql
no matching manifest for linux/arm64/v8 in the manifest list entries

Works as expected.

environment variable is set

$ DOCKER_DEFAULT_PLATFORM=linux/x86_64 docker pull mysql:5.7
5.7: Pulling from library/mysql
Digest: sha256:4149a92977a54d27cbd6f81cca3817e6278a844d566b45f9ff1908bb2714b1ca
Status: Image is up to date for mysql:5.7
docker.io/library/mysql:5.7

Works as expected.

Steps To Reproduce

docker compose

Let’s use this super simple demo file:

version: "3"

services:
  db:
    image: mysql:5.7
    environment:
      - MYSQL_ROOT_PASSWORD=secure1234
    ports:
      - "3306:3306"

No platform specified

$ docker compose up
[+] Running 1/0
 ⠿ Container test-db-1  Created                                                                                                                                                                                                          0.0s
Attaching to test-db-1
test-db-1  | 2022-12-03 09:07:12+00:00 [Note] [Entrypoint]: Entrypoint script for MySQL Server 5.7.40-1.el7 started.
test-db-1  | 2022-12-03 09:07:13+00:00 [Note] [Entrypoint]: Switching to dedicated user 'mysql'
…

Does not work as expected (does not complain).

Environment variable is set

$ DOCKER_DEFAULT_PLATFORM=linux/x86_64 docker compose up
[+] Running 2/0
 ⠿ Network test_default                                                                                                                              Created                                                                             0.0s
 ⠿ Container test-db-1                                                                                                                               Created                                                                             0.0s
 ⠋ db The requested image's platform (linux/amd64) does not match the detected host platform (linux/arm64/v8) and no specific platform was requested                                                                                     0.0s
Attaching to test-db-1
test-db-1  | 2022-12-03 09:09:09+00:00 [Note] [Entrypoint]: Entrypoint script for MySQL Server 5.7.40-1.el7 started.
test-db-1  | 2022-12-03 09:09:10+00:00 [Note] [Entrypoint]: Switching to dedicated user 'mysql'
…

Does not work as expected (complains although a default is set)

This has worked before, we are using docker compose every day. This behavior was introduced with the newest version of Docker Desktop. If you export the variable instead of setting it, the behavior is the same.

In the Release notes for v2.13.0 there is even a bullet point stating:

Compose now uses the platform value defined by DOCKER_DEFAULT_PLATFORM when no service.platform defined. Fixed compose#9889

Platform in compose file

Add the platform key to the compose file:

version: "3"

services:
  db:
    image: mysql:5.7
    platform: linux/x86_64
    environment:
      - MYSQL_ROOT_PASSWORD=secure1234
    ports:
      - "3306:3306"

… and it works:

$ docker compose up
[+] Running 2/0
 ⠿ Network test_default  Created                                                                                                                                                                                                         0.0s
 ⠿ Container test-db-1   Created                                                                                                                                                                                                         0.0s
Attaching to test-db-1
test-db-1  | 2022-12-03 09:16:43+00:00 [Note] [Entrypoint]: Entrypoint script for MySQL Server 5.7.40-1.el7 started.
test-db-1  | 2022-12-03 09:16:44+00:00 [Note] [Entrypoint]: Switching to dedicated user 'mysql'
…

It still works if you specifically set or export the environment variable.

This is the expected behavior, but we do not want to specify the platform in every service in the docker-compose.yml.

Compose Version

v2.13.0

Docker Environment

Client:
 Context:    default
 Debug Mode: false
 Plugins:
  buildx: Docker Buildx (Docker Inc., v0.9.1)
  compose: Docker Compose (Docker Inc., v2.13.0)
  dev: Docker Dev Environments (Docker Inc., v0.0.5)
  extension: Manages Docker extensions (Docker Inc., v0.2.16)
  sbom: View the packaged-based Software Bill Of Materials (SBOM) for an image (Anchore Inc., 0.6.0)
  scan: Docker Scan (Docker Inc., v0.22.0)

Server:
 Containers: 2
  Running: 0
  Paused: 0
  Stopped: 2
 Images: 121
 Server Version: 20.10.21
 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: runc io.containerd.runc.v2 io.containerd.runtime.v1.linux
 Default Runtime: runc
 Init Binary: docker-init
 containerd version: 770bd0108c32f3fb5c73ae1264f7e503fe7b2661
 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: aarch64
 CPUs: 4
 Total Memory: 15.61GiB
 Name: docker-desktop
 ID: VLWY:LLVX:OOSQ:EUFT:3YWZ:AYYJ:AV3Y:RJZM:JJBU:YUGN:I2X7:JM66
 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

Anything else?

No response

@laurazard
Copy link
Member

laurazard commented Dec 6, 2022

Hi @jensschulze, thanks for the report.

I'm having a hard time fully replicating your bug.

What I can replicate:

  • without a platform key in my service definition, even having DOCKER_DEFAULT_PLATFORM I get the warning message, which is incorrect behavior as a specific platform is set

What I can't replicate:

  • Without a platform key in my service definition, without DOCKER_DEFAULT_PLATFORM set, I get
no matching manifest for linux/arm64/v8 in the manifest list entries

which is the expected behaviour iirc.

What I think might be happening to you (happened to me while testing):

When you run compose up (without DOCKER_DEFAULT_PLATFORM, with your compose.yaml, if you already have a mysql:5.7 image previously downloaded (with DOCKER_DEFAULT_PLATFORM=linux/x86_64 docker pull mysql:5.7, Compose will use the specified image which you already have explicitly downloaded with the set platform, and as such will not fail with no matching manifest for linux/arm64/v8 in the manifest list entries, as no pull is happening.

@jensschulze
Copy link
Author

Hi @laurazard, thanks for testing and your explanation of the second case! Certainly you are right, I did not delete the mysql:5.7 image before executing the first test with docker compose.

I did not know that Compose chooses the platform on the basis of the image already present. When I delete the MySQL image first, I get the result you expected.

* docker compose up
[+] Running 0/1
 ⠹ db Pulling                                                                                                                                                                                                                            2.2s
no matching manifest for linux/arm64/v8 in the manifest list entries

@jensschulze
Copy link
Author

Hi @laurazard, possibly the detail went down, but there was still incorrect behavior that you could replicate. Is this bug being tracked elsewhere?

@laurazard
Copy link
Member

Hiya @jensschulze. Sorry, I closed this prematurely 😅 I'm putting up a PR to fix the other issue today :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants