414

I'm running the latest build of the Docker Apple Silicon Preview. I created the tutorial container/images and it works fine. When I went to create a custom YAML file and run docker-compose I get the following error when pulling mysql:

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

Here is a snippet from my YAMl file:

version: '3'

services:
  # Database
  db:
    image: mysql-server:5.7
    volumes:
      - db_data:/var/lib/mysql
    restart: always
    environment:
      MYSQL_ROOT_PASSWORD: pass
      MYSQL_DATABASE: wp
      MYSQL_USER: wp
      MYSQL_PASSWORD: wp
    networks:
      - wpsite 

I've tried :latest and :8 which result in the same error. It pulls phpmyadmin and wordpress fine.

Sam
  • 5,150
  • 4
  • 30
  • 51
  • 3
    And *have* the MySQL maintainers pushed an image for that architecture? – jonrsharpe Dec 26 '20 at 13:22
  • 1
    There are only amd64 images... [mysql Tags \- Docker Hub](https://hub.docker.com/_/mysql?tab=tags&page=1&ordering=last_updated) – Akihito KIRISAKI Dec 26 '20 at 13:40
  • Strange, I believe MySQL supports ARM Source: https://mysqlonarm.github.io/Running-MySQL-on-ARM/ – Sam Dec 26 '20 at 13:58
  • 1
    @AkihitoKIRISAKI https://hub.docker.com/r/mysql/mysql-server/tags?page=1&ordering=last_updated (server) looks the same but that will install. – Sam Dec 26 '20 at 14:01
  • 1
    @Sam `mysql-server:5.7` version is quite too old to support arm64! https://hub.docker.com/layers/mysql/mysql-server/5.7/images/sha256-96f7f199868eaaf9dd9c3cff47021831f5525047b41b0c6a8bf1187936a3e9d2?context=explore – Akihito KIRISAKI Dec 26 '20 at 14:09
  • Where a `linux/amd64` image is available, I believe this is the underlying issue: https://github.com/containerd/containerd/issues/3225 – Aidan Feldman Feb 11 '23 at 00:08
  • Checkout second answer https://stackoverflow.com/a/67361161/316343 if you're not looking specifically for mysql. – Jahan Zinedine Feb 11 '23 at 18:32

24 Answers24

737

Well, technically it will not solve your issue (running MySQL on ARM), but for the time being, you could add platform to your service like:

services:
  db:
    platform: linux/x86_64
    image: mysql:5.7
    ...

Alternatively, consider using MariaDB, which should work as a drop-in replacement like e.g. this:

services:
  db:
    image: mariadb:10.5.8
    ...

Both ways work for me on M1 with the Docker Preview

Stefan W
  • 7,386
  • 1
  • 5
  • 2
  • Same thing i did for "percona" image(mysql on steroids) also. Thank you! – Shyam Jan 09 '21 at 19:14
  • 4
    https://docs.docker.com/docker-for-mac/apple-m1/ I see the documentation has been updated to include instructions for running under emulation (platform linux/amd64 flag) and to encourage mariadb support. – Sam Jan 25 '21 at 03:54
  • 19
    For docker (without compose) you can do: `docker run --platform linux/x86_64 mysql` which pulls and runs the correct images on an M1 too. Thank you so much for this post! – JasonD Feb 01 '21 at 01:30
  • 1
    Can i suggest you to change the mysql version to 8 ? The edit is to short for be submitted – jibeeeee Feb 09 '21 at 21:29
  • Is there a way to set an image based on the current arch in the docker compose file? Say, use mysql if running on x86 or use mariadb if running on arm? – cumanzor Mar 10 '21 at 17:21
  • @jibeeeee, the original question asked about mysql5.7 . You can probably just use mysql-server:8.0 or whichever version you prefer. – Ben Wheeler Mar 19 '21 at 13:49
  • Can our employers with Intel i7 use same configuration? – Alex Shtromberg Jul 29 '21 at 15:56
  • 3
    @AlexShtromberg - this should work also on Intel machines, as it's a x86 architecture... – Stefan W Aug 01 '21 at 06:32
  • Worked just fine with Mac OS running under Apple Silicon M1. Thank you! – Renoir Reis Sep 07 '21 at 16:26
  • The alternative you suggested, `mariadb` container worked great apple silicon / arm – CDM social medias in bio Sep 27 '21 at 18:32
  • Adding `platform: linux/x86_64` resolved the problem for me on an M1 Mac. – Porter Lyman Oct 09 '21 at 02:42
  • As this seems to be an accepted answert, I wanted to add, that updating a version to something like ``mysql:5.7.34`` might already fix the issue. I have rosetta2 and docker with m1 support installed. – chAlexey Nov 08 '21 at 13:34
  • MariaDB is not a drop-in replacement (anymore). Since MySQL 5.7, versions are deviating to the point where restoring dumps made with `mysqldump` on MySQL 5.7 will not restore on MariaDB anymore. See e.g. https://stackoverflow.com/questions/54875134/moving-to-mariadb-from-mysql-foreign-key-constraint-is-incorrectly-formed – Stijn de Witt Jan 13 '22 at 10:11
  • this solution add platform in docker-compose is perfect, simple and solve my problem – Edson Filho Apr 28 '22 at 18:26
  • i was with the same problem with sonarqube image and this works for me – LEONARDO PEREIRA RODRIGUES Jul 22 '22 at 13:28
  • FWIW, neither this nor *any* of the answers to this question worked for me (I got the same error as the OP). My machine is an M1 MBP with the M1 Max chip. As far as my personal experience goes, it is still impossible to run MySQL under Docker, both with and without emulation, in late 2022. It's hard for me to believe that no one has successfully compiled and published MySQL for M1. – Aquarelle Sep 05 '22 at 21:09
  • I tried to use this solution in my docker-compose file, but my CMS app was locally very slow and pages took more than 10 sec. to load (also docker desktop shown that I might have slow perf with this container)... Then I removed platform, updated to MySQL 8, and there was no issue for me - it loads in tens of milliseconds again... – dkocich Nov 24 '22 at 11:41
  • I experienced the same problem with my Mac M2 machine and this resolved it – Tito Lulu Jan 12 '23 at 13:38
  • Checkout https://stackoverflow.com/a/67361161/316343 if you're not looking specifically for mysql. – Jahan Zinedine Feb 11 '23 at 18:32
277

same problem for m1 mac just run this command

docker pull --platform linux/x86_64 mysql
mstgnz
  • 2,988
  • 1
  • 9
  • 13
157

From this answer, I added this to my local docker-compose.override.yml

services:

  mysql:
    platform: linux/amd64
Mathias Brodala
  • 5,905
  • 13
  • 30
Luke Madhanga
  • 6,871
  • 2
  • 43
  • 47
59

Oracle maintains a MySQL 8.0.23 docker image for arm64.
https://hub.docker.com/r/mysql/mysql-server

To use it in your docker-compose file

version: "3.8"
services:
  mysql:
    container_name: mycontainername
    image: mysql/mysql-server:8.0.23
    ports:
      - "3306:3306"
    environment:
      MYSQL_ROOT_PASSWORD: root
      MYSQL_DATABASE: mydatabasename
      MYSQL_ROOT_HOST: "%"
    command: --lower_case_table_names=1
bpossolo
  • 849
  • 5
  • 6
  • 1
    Worked like a charm, Mac Mimi M1, thank you! – csaborio Aug 26 '21 at 05:43
  • I also used `command: --default-authentication-plugin=mysql_native_password` based on https://stackoverflow.com/a/52789430/332798 – tmm1 Mar 22 '22 at 22:23
  • worked fine to me to. MacBook Pro m1 – Pedro Soares Apr 01 '22 at 02:23
  • Worked for me. Mac Air M1 2020 Big Sur. I tried the chose answer but I was warned that emulating linux/x86_64 could generate errors ou memory overhead. Thank U very much. – Écio Silva Jun 07 '22 at 22:06
  • This did not work for me at all. I got the same error ("no matching manifest for linux/arm64/v8 in the manifest list entries") as the OP. I also tried setting the platform to "linux/amd64", "linux/x86_64", and "linux/x86_64/v8", and still received the same error. It looks like it's still impossible to run MySQL under Docker, with and without emulation, even in September of 2022. I can't believe no one anywhere has compiled MySQL for M1. – Aquarelle Sep 05 '22 at 21:02
  • @Aquarelle clearly there is something wrong with your setup because I and countless others are running MySQL perfectly fine (with and without emulation) on Apple M1 processors. It you took a moment to read the Dockerfile for the image I mentioned above, you'd see Oracle explicitly says its compiled for ARM. https://hub.docker.com/r/mysql/mysql-server – bpossolo Sep 06 '22 at 22:58
  • @bpossolo Forgive the angry rant. I may even delete my comment, if that's possible. The issue was entirely PEBKAC (I had been pointing docker compose at an old, outdated compose file in a shell script, and I didn't realize it until a couple hours ago, at which point I facepalmed and then updated the script). Everything's working beautifully now. Sorry! – Aquarelle Sep 08 '22 at 00:00
  • glad you sorted it out! – bpossolo Sep 09 '22 at 18:39
40

Docker on its official documentation says:

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.

(source here)

So what you should do to make your project work is to add platform: linux/amd64 to your docker-compose.yml.

It would look like:

services:
    mysql:
        image: mysql:5.7
        platform: linux/amd64
        ...

As you can imagine probably the performance won't be the same.

octaedro
  • 609
  • 6
  • 8
34

I had a similar issue, solved with this line in my dockerfile:

before

FROM ubuntu:18.04

after

FROM --platform=linux/x86_64 ubuntu:18.04
Misha Ishikawa
  • 343
  • 2
  • 8
  • This workd great you just have to add this to your mysql docker file for laradock FROM --platform=linux/x86_64 mysql:${MYSQL_VERSION} – Louwki Jun 05 '21 at 19:40
20

This works for me in mac M1, specifying platform key inside service.

services:
  mysql:
    platform: linux/amd64
    image: mysql:latest
    command: --default-authentication-plugin=mysql_native_password
    restart: always
    environment:
      MYSQL_ROOT_PASSWORD: example
    ports:
      - 3306:3306
Ashwin J
  • 662
  • 7
  • 12
14

You just need to specify the platform after specifying the image. Working on M2 processor

version: '3'

services:
  # Database
  db:
    image: mysql-server:5.7
    platform: linux/amd64 <--------- this line to add
    volumes:
      - db_data:/var/lib/mysql
    restart: always
    environment:
      MYSQL_ROOT_PASSWORD: pass
      MYSQL_DATABASE: wp
      MYSQL_USER: wp
      MYSQL_PASSWORD: wp
    networks:
      - wpsite 
chavy
  • 841
  • 10
  • 20
13

For anyone struggling to make it work with a specific version, the following didn't work for me:

docker run --platform linux/x86_64 mysql:5.7.26 -e MYSQL_ROOT_PASSWORD=pass

but this did:

 docker run --platform linux/x86_64 mysql:5.7 -e MYSQL_ROOT_PASSWORD=pass
Dharman
  • 30,962
  • 25
  • 85
  • 135
Hugo sama
  • 899
  • 1
  • 9
  • 19
11

can try start/run a container (for mac m1)

docker run -d -p 3306:3306 --name mysql --platform linux/x86_64 --env MYSQL_ROOT_PASSWORD=12345 mysql
khoi
  • 940
  • 1
  • 14
  • 29
8

Please refer to the following link for known issues. In your Mac's terminal run

softwareupdate --install-rosetta

and then in docker-compose have something along the lines of

mysql_gdpr:
    platform: linux/x86_64
    image: mysql/mysql-server:8.0.23
    ports:
      - "3306:3306"
    environment:
      MYSQL_DATABASE: "user_security"
      MYSQL_RANDOM_ROOT_PASSWORD: 1
      MYSQL_USER: "security"
      MYSQL_PASSWORD: "pleasechangeit"
Viswanath
  • 1,413
  • 13
  • 25
8

In your Dockerfile for mysql if you have the following

FROM mysql:8.0.28

change it to

FROM --platform=linux/x86_64 mysql:8.0.28

because the Docker in Apple M1 is going to look for an ARM image, and MySQL doesn't publish ARM images, so that's why you are getting

failed to solve with frontend dockerfile.v0: failed to create LLB definition: no match for platform in manifest

with the --platform flag, even though we are in ARM processor we are telling docker that we want to use the x86_64 image

Shobi
  • 10,374
  • 6
  • 46
  • 82
8

I am the only one with Mac (M1 chip) in my team. All others have windows.
So if I want to be compatible with others in git I need to use the next solution.

I created a new docker-compose file docker-compose.mac.yml in the same directory as the normal one docker-compose.yml. (Instead of the word mac can be used anything)

And inside I have only this code.

version: '2'
services:
  mysql:
    image: mysql:8.0.26
    platform: linux/amd64

I am starting it with this command:

docker-compose -f docker-compose.yml -f docker-compose.mac.yml up

What does it do? It will copy everything from docker-compose.yml file and paste it into docker-compose.mac.yml file. But without replacing.

In my opinion, it is super useful in a bigger teams with different computers.

Martin54
  • 1,349
  • 2
  • 13
  • 34
3

Using this below image solved my problem.

mysql/mysql-server:8.0.23
Gokce Demir
  • 459
  • 4
  • 5
2

Please note that when using --platform linux/x86_64 on arm64/v8 you may lose Linux Native AIO support.

Check out the docker container logs:

[ERROR] [MY-012585] [InnoDB] Linux Native AIO interface is not supported on this platform. Please check your OS documentation and install appropriate binary of InnoDB.
[Warning] [MY-012654] [InnoDB] Linux Native AIO disabled.

Consider using mysql/mysql-server instead, as it has arm64/v8 support out of the box.

aik.fiend
  • 21
  • 1
2

This Github repo allows to build a MySQL 5.7 aarch64 image.

Building it with the following command (naming it the same as the official mysql:5.7 image) it will be used by default by all your docker-compose configurations or Dockerfiles that specify mysql:5.7.

docker build -t mysql:5.7 .

It means that you won't have updates from the official MySQL Dockerhub repo anymore, but as a temporary drop-in replacement I find it useful.

Simon
  • 3,580
  • 2
  • 23
  • 24
2

I've also encountered this issue on M1 Pro and to solve the most stable way for me was to disable buildkit in the Docker engine settings, meaning setting to false instead the default true. There is also an open issue here https://github.com/docker/for-mac/issues/5873

Elio Ermini
  • 289
  • 5
  • 19
2

Look at this github post

Since "Oracle only supplies pre-compile Arm64" binaries, you have it there with

Image --> mysql:8.0-oracle

docker run -d --name mysql-8 -p 3306:3306 -e MYSQL_ROOT_PASSWORD=<your_password> mysql:8.0-oracle

danronmoon
  • 3,814
  • 5
  • 34
  • 56
Sumit S
  • 516
  • 5
  • 17
2

Change the platform in docker command

Param : --platform linux/x86_64

skgodara
  • 21
  • 1
2

To resolve the issue, we need to pass the platform with value into your docker image/file.

Using docker-compose.yaml file:

services:
  db:
    platform: linux/x86_64
    image: mysql:5.7
    ...

Using Docker file:

FROM --platform=linux/x86_64 mysql:5.7

Using docker pull command:

docker pull --platform=linux/x86_64 mysql:5.7

Using DOCKER_DEFAULT_PLATFORM parameter:

export DOCKER_DEFAULT_PLATFORM=linux/x86_64

Some of other well known platforms are: linux/amd64, linux/arm64 etc.

Ranga Reddy
  • 2,936
  • 4
  • 29
  • 41
2
  • In my M1-Pro chip, worked with this command.

docker run --platform linux/amd64 --name mysql-5-7 -e MYSQL_ROOT_PASSWORD=root -p 3306:3306 -d mysql:5.7

Manju N
  • 886
  • 9
  • 14
1

Attempts to run x86 containers on M1 machines under emulation can crash. Even when the containers do run correctly under emulation, they will be slower and use more memory than the native equivalent. From here https://docs.docker.com/desktop/mac/apple-silicon/#known-issues

NeptunB
  • 11
  • 2
1

This is for anyone who is here for the same issue but with the ibmcom/db2

You can use the below command to pull the db2 image

docker pull --platform linux/x86_64 ibmcom/db2:latest
Achintha Isuru
  • 2,662
  • 18
  • 24
-1

I have the M1 chip.

Today I found this works fine in the latest KSQL master branch. Here's the commands

git clone https://github.com/confluentinc/ksql.git
cd ksql
docker-compose up -d

It magically brings up the Zookeeper, three instances of Kafka server, a Schema Registry and a CLI.

Reference: KSQLDB Docker Guide

SydMK
  • 425
  • 4
  • 12