compose icon indicating copy to clipboard operation
compose copied to clipboard

`docker-compose up` prioritizes local platform when pulling images, causing an error when an image for the local platform is unavailable

Open tronicboy1 opened this issue 2 years ago • 4 comments

Description

Executing docker-compose up can lead to an error when a necessary image for the local platform is not available.

This occurs on ARM machines, even when the platform is set in the docker-compose.yaml file.

Steps to reproduce the issue:

  1. Create a docker-compose.yaml with mysql:5.7 as a dependency.
  2. Set the platform of the mysql container to linux/amd64
  3. On an ARM machine, execute docker-compose up

Describe the results you received:

Docker compose exits with an error stating that the image cannot be found.

Describe the results you expected:

I feel as though Docker Compose should look for the image regardless of platform or look for the image based on the platform setting in the docker-compose.yaml file.

Additional information you deem important (e.g. issue happens only occasionally):

This issue can be resolved if one pulls the necessary image before executing docker-compose up.

docker pull --platform linux/amd64 mysql:5.7
docker-compose up

Output of docker compose version:

Docker Compose version v2.6.1

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.6.1)
  extension: Manages Docker extensions (Docker Inc., v0.2.7)
  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: 4
  Running: 4
  Paused: 0
  Stopped: 0
 Images: 61
 Server Version: 20.10.17
 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: 10c12954828e7c7c9b6e0ea9b0c02b01407d3ae1
 runc version: v1.1.2-0-ga916309
 init version: de40ad0
 Security Options:
  seccomp
   Profile: default
  cgroupns
 Kernel Version: 5.10.104-linuxkit
 Operating System: Docker Desktop
 OSType: linux
 Architecture: aarch64
 CPUs: 5
 Total Memory: 7.765GiB
 Name: docker-desktop
 ID: NJV6:RLVM:MND5:P7AR:752U:J7OT:KQGA:JLKI:AA2G:SLJM:XOQY:IZMO
 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:

tronicboy1 avatar Sep 14 '22 03:09 tronicboy1

Can you confirm this is the error you're seeing?

Error response from daemon: image with reference postgres was found but does not match the specified platform: wanted linux/amd64, actual: linux/arm64/v8

milas avatar Sep 15 '22 12:09 milas

@milas

Thanks for looking into this for me!!

Here is the error that I received:

Creating network "s4_query_admin_fe_default" with the default driver
Pulling db (mysql:5.7)...
5.7: Pulling from library/mysql
ERROR: no matching manifest for linux/arm64/v8 in the manifest list entries

Please let me know if there is anything else I can do to help!

tronicboy1 avatar Sep 16 '22 01:09 tronicboy1

Can you give a more complete version of your Compose YAML?

I'm on an ARM64 machine using the following Compose file:

services:
  db:
    image: mysql:5.7
    platform: linux/amd64
❯ docker compose version
Docker Compose version v2.6.0


❯ docker compose up --wait
[+] Running 12/12
 ⠿ db Pulled                                                                                                                                           7.6s
   ⠿ 9815334b7810 Pull complete                                                                                                                        4.4s
   ⠿ f85cb6fccbfd Pull complete                                                                                                                        4.4s
   ⠿ b63612353671 Pull complete                                                                                                                        4.5s
   ⠿ 447901201612 Pull complete                                                                                                                        4.6s
   ⠿ 9b6bc806cc29 Pull complete                                                                                                                        4.7s
   ⠿ 24ec1f4b3b0d Pull complete                                                                                                                        4.7s
   ⠿ 207ed1eb2fd4 Pull complete                                                                                                                        5.2s
   ⠿ 27cbde3edd97 Pull complete                                                                                                                        5.2s
   ⠿ 0a5aa35cc154 Pull complete                                                                                                                        6.6s
   ⠿ e6c92bf6471b Pull complete                                                                                                                        6.6s
   ⠿ 07b80de0d1af Pull complete                                                                                                                        6.6s
[+] Running 2/2
 ⠿ Network mysql-platform_default  Created                                                                                                             0.0s
 ⠿ Container mysql-platform-db-1   Healthy                                                                                                             0.9s


❯ docker compose images
Container             Repository          Tag                 Image Id            Size
mysql-platform-db-1   mysql               5.7                 daff57b7d2d1        430MB


❯ docker image inspect -f '{{ .Architecture }}' daff57b7d2d1
amd64

milas avatar Sep 19 '22 20:09 milas

Ah, I think based on the error text you are using Docker Compose v1 for your commands.

In Docker Desktop, ensure that Compose v2 is enabled on the "General" tab to change the docker-compose symlink/alias to point to v2.

Note that docker compose will always invoke v2, which is now a plugin and the preferred way to invoke it (no hyphen).

milas avatar Sep 19 '22 20:09 milas

Hello @tronicboy1 Can you confirm that you wasn't using Compose v1 as @milas mentioned? If you are using Compose v2, could you test with the latest release, I think this issue may have been solved by this PR few weeks ago.

glours avatar Oct 24 '22 19:10 glours

seems to me this issue has been fixed by Compose v2, especially thanks to https://github.com/docker/compose/commit/7c5675c30631178c4955856fb9ce6eecc0898525#diff-2a6b4d85b4172a20829d65bb72126a9402faf6490ee556964f6a4e167cf3a8bbR180-R183

ndeloof avatar Dec 13 '22 17:12 ndeloof

@milas My apologies for the late response!

I was using the docker-compose command so most likely it was defaulting to v1 as you say.

I didn’t know that docker compose was the preferred method! Thank you for that.

tronicboy1 avatar Apr 14 '23 23:04 tronicboy1

I think it’s safe to say this issues should be resolved. Shall we close this?

tronicboy1 avatar Apr 14 '23 23:04 tronicboy1