docker run mysql image command not working [MacBook Pro M1]

Viewed 10526

I was following the official docker labs hands-on tutorial for multi-container apps tutorials. While running the below command on MacBook Pro M1 terminal

docker run -d `
    --network todo-app --network-alias mysql `
    -v todo-mysql-data:/var/lib/mysql `
    -e MYSQL_ROOT_PASSWORD=secret `
    -e MYSQL_DATABASE=todos `
    mysql:5.7

I am getting the below error.

docker: no matching manifest for linux/arm64/v8 in the manifest list entries.

3 Answers

If anyone else runs into this issue while following the guide on a Mac M1 machine specifically, the quickest work-around is probably to add the flag:

--platform linux/amd64

like

docker run -d \
    --platform linux/amd64 \
    --network todo-app --network-alias mysql \
    -v todo-mysql-data:/var/lib/mysql \
    -e MYSQL_ROOT_PASSWORD=secret \
    -e MYSQL_DATABASE=todos \
    mysql:5.7

Credits to https://github.com/docker/getting-started/issues/144

When you check the offical mysql image, you can see there is no mention of linux/arm64/v8

In the case of mysql docker docs even states that:

Not all images are available for ARM64 architecture. You can add --platform linux/amd64 to run an Intel image under emulation. In particular, the mysql image is not available for ARM64. You can work around this issue by using a mariadb image.

So you could use mariadb as a workaround, until they offer official support for mysql like so:

docker run -d \
  -v todo-mysql-data:/var/lib/mysql \
  -e MYSQL_ROOT_PASSWORD=secret \
  -e MYSQL_DATABASE=todos \
  mariadb:10.5

See: github.com/docker-library/mysql/issues/318

If you really need the mysql image you could try the workaround mentioned in the same issue here. As of now I can't test this, because I don't have an m1 macbook.

Incase you are using docker compose for your container ochestration you can have your docker-compose.yaml file mirror something similar to this

services:
  mysql:
  platform: linux/amd64
  #you can use whatever image you prefer
  image: "mysql:5.7" 
  
Related