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

4

9

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.

Vacuous answered 25/4, 2021 at 16:16 Comment(1)
Please help to share your docker-compose.ymlBiosynthesis
A
26

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

Amido answered 25/5, 2021 at 12:37 Comment(1)
This seems to work for a M1 Macbook ProJohannajohannah
U
3

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.

Unconsidered answered 25/4, 2021 at 16:34 Comment(1)
P
1

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" 
  
Pliner answered 13/6, 2022 at 14:9 Comment(0)
A
0

Following works for me MACOS M2

  mysql:
    image: mysql:8-oracle
    container_name: mysql
    restart: on-failure
    # platform: linux/amd64
    environment:
        - MYSQL_ROOT_PASSWORD=root
        - MYSQL_DATABASE=mydb
    # volumes:
    #     - /Users/piash/mysql:/var/lib/mysql
    ports:
        - 3308:3306

reference https://github.com/docker-library/mysql/issues/865

Apograph answered 12/8 at 19:2 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.