Docker Mysql in Macbook Air M1 - I Need Help

Hello, I need help.

I’m trying to install mysql on docker with the command:

" docker run --name mysqlbd1 -e MYSQL_ROOT_PASSWORD=bootcamp -p
“3307:3306” -d mysql "

but it comes back with the following message and I don’t know what else to do:

" Unable to find image ‘mysql:latest’ locally
latest: Pulling from library/mysql
docker: no matching manifest for linux/arm64/v8 in the manifest list entries.
See ‘docker run --help’. "

I’m using a Macbook Air M1 and I’m starting to study development. Thanks

mysql was one of the first image I tried on my new Mac but MySQL doesn’t support ARM containers. You can try to run it with the platform option:

docker run --platform linux/amd64 ...

I think it did not work me either. I am not sure, so you should try it. If it doesnt work, you can try mariadb which is similar to mysql and supports ARM containers

My Docker environment is really acting up - perhaps you have experience with that ?

√ sten % docker compose build db
Sending build context to Docker daemon     428B
Step 1/6 : FROM mysql:8.0.27
8.0.27: Pulling from library/mysql
1 error occurred:
        * Status: no matching manifest for linux/arm64/v8 in the manifest list entries, Code: 1

So - then I pull mysql for the platform (M1’s should be able to run amd64 AFAIK)

?1 sten % docker pull --platform=linux/amd64 mysql:8.0.27
8.0.27: Pulling from library/mysql
Digest: sha256:e9027fe4d91c0153429607251656806cc784e914937271037f7738bd5b8e7709
Status: Downloaded newer image for mysql:8.0.27
docker.io/library/mysql:8.0.27
√ sten % docker compose build db                        
Sending build context to Docker daemon     428B
Step 1/6 : FROM mysql:8.0.27
 ---> 3218b38490ce
Step 2/6 : COPY ./my.cnf /etc/mysql/conf.d/my.cnf
 ---> Using cache
 ---> 55f64854d0bb
Step 3/6 : RUN mkdir -p /var/log/mysql
 ---> Using cache
 ---> 48f15258c87f
Step 4/6 : RUN chown mysql:mysql /var/log/mysql
 ---> Using cache
 ---> 308c3403f425
Step 5/6 : RUN mkdir -p /var/run/mysql
 ---> Using cache
 ---> 1dcb4fef4c77
Step 6/6 : RUN chown mysql:mysql /var/run/mysql
 ---> Using cache
 ---> fc59695bc113
Successfully built fc59695bc113
Successfully tagged mysql_db:latest

And then I believe all is good - but sadly not!

√ sten % docker compose up db   
[+] Running 0/1
 ⠿ db Error                                                                                                                                                                                                                             1.8s
Sending build context to Docker daemon     428B
Step 1/6 : FROM mysql:8.0.27
8.0.27: Pulling from library/mysql
1 error occurred:
        * Status: no matching manifest for linux/arm64/v8 in the manifest list entries, Code: 1

This is what my docker-compose.yml looks like

version: "3.9"
services:
  db:
    build: mysql
    platform: linux/amd64
    image: mysql_db
    container_name: mysql_db
    command: [ "--default-authentication-plugin=mysql_native_password" ]
    ports:
      - "3306:3306"
    volumes:
      - ~/src/mysql_data:/var/lib/mysql
    environment:
      MYSQL_ROOT_PASSWORD: secret
      MYSQL_DATABASE: sten_development
  sten:
    build: .
    command: bash -c "rm -f tmp/pids/server.pid && bundle exec rails s -p 3000 -b '0.0.0.0'"
    volumes:
      - ./src:/app
    ports:
      - "3000:3000"
    depends_on:
      - db
    environment:
      SQL_HOST: db
      SQL_NAME: sten
      SQL_USER: root
      SQL_PASSWORD: password

I solved this issue by doing this:

# mysql/Dockerfile
FROM mysql/mysql-server:latest

and then in my docker-compose.yml

  db:
    build: mysql
    image: mysql_db
    container_name: mysql_db
    command: [ "--default-authentication-plugin=mysql_native_password" ]
    ports:
      - "3306:3306"
    volumes:
      - ~/src/mysql_data:/var/lib/mysql
    environment:
      MYSQL_ROOT_PASSWORD: secret
      MYSQL_DATABASE: sten_development

Apparently Oracle keeps a mysql/mysql-server image updated with support for linux/amd64 - yeah :partying_face:

1 Like