Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Docker image run in m1 processor

I can only play in my macbook air m1 with docker preview and i can't run an image of mysql with version 8.0.22 through a docker-compose file.

docker-compose set

The command i run is : docker-compose up -d mysql

How can I solve this problem?

like image 303
Ioannis Panagopoulos Avatar asked Mar 03 '21 11:03

Ioannis Panagopoulos


People also ask

Can M1 Macs run Docker?

Docker image was built in only seven minutes on MacBook M1 Pro, which was even better than the build time on my new VPS. This is not surprising, I gave Docker quite a lot of resources. But it also shows that if there are not too many I/O disk operations, performance is quite good.

Can I run x86 Docker image on M1?

Although the M1 version docker desktop allows users to run x86 docker images under emulation, it will be a more efficient solution to offer your software as a “universal” Multi-Arch docker image that can serve both your ARM (M1) and x86 users.

How do I start Docker on Mac M1?

To run the Docker Desktop, simply double-click the Docker app in the Application folder. To confirm that the Docker Desktop is running, you should be seeing the Docker icon on the Menu Bar and it says Docker Desktop is running… You will also see the below Docker Desktop app window.

Is Mac M1 ARM64?

Apple Silicon is a growing family of Apple-designed 64-bit ARM SoCs. The M1 is the first generation of the family. ARM64 is an umbrella term for the 64-bit ARM Instruction Set Architecture (ISA) which Apple, and others, license from ARM.

What Docker images are available for the Mac M1?

Many Docker images are made available for the M1. Not every Docker image maintainer did that. Most official Docker Images created by Docker have support for ARM64. Docker Images with the ARM64 tag run on the Mac M1 natively. If you use Rosetta 2, you can run amd64 images, but they can cause performance issues.

Can you dual-run the Intel and M1 versions of Docker desktop?

Can you dual-run the Intel and M1 versions of Docker Desktop on the same unit? You can run ARM or Intel Docker containers on the Apple M1 Mac with Docker Desktop for Mac M1. I do it all the time. The default, of course, is to run the ARM version but if you use the --platform linux/amd64 parameter Docker will run the Intel version for you.

Can Docker run on Apple’s M1 (aarm64) chip?

Unfortunately, this package isn’t compatible with Apple’s M1 (aarm64) chip due to the standalone ruby (Intel/x86-only) that’s packaged with it. Instead of trying to have two node installations for each platform, I decided to try and get docker to build and run my app images using the amd64 platform. And it works!

How do I build a dockerfile for multiple platforms?

This lets you specify multiple docker platforms at once. To build your Dockerfile for typical x86 systems and Apple Silicon Macs, run docker buildx build --platform linux/amd64,linux/arm64 --push -t <tag_to_push> . Done.


Video Answer


3 Answers

We've just ran into this issue, and I took the solution from this answer. You can specify your platform in the docker-compose file, so in your case it would look like:

services:
  mysql:
    image: mysql:8.0.22
    platform: linux/x86_64
    container_name: mysqldb
    restart: always
    ports:
      - 3306:3306
    volumes:
      - mysql:/var/lib/mysql
    environment:
      - MYSQL_ROOT_PASSWORD=test
      - MYSQL_DATABASE=DATA

In our company, we use M1 and Intel Macs and this solution makes mysql image available for both.

like image 111
maestro Avatar answered Oct 16 '22 17:10

maestro


M1 is ARMv8 (aarch64) architecture and majority of the images are X86 (amd64). The whole emulation process based on bitfmt that allows to run containers from another architecture is still not stable for the ARMv8 release of Docker for Mac, so you would need to wait some time.

One way to overcome this problem is to build your own image of mysql for ARM64, by starting from some of the linux distributions such as alpine, debian, ubuntu and installing the mysql servers (same as you would have done on a bare-metal installation).

You can find lot's of containers that are already available in docker hub marked as ARM64v8 so this can be a good starting point to create your image.

like image 5
jordanvrtanoski Avatar answered Oct 16 '22 16:10

jordanvrtanoski


I also struggled with X86 (amd64) images on my M1 Mac. But in your particular case, I would recommend to simply use MariaDB (image mariadb). All things I tried so far, have been fully compatible with MySQL and MariaDB is available for ARM64.

like image 2
lexos Avatar answered Oct 16 '22 16:10

lexos