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?
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.
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.
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.
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.
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 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.
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!
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.
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.
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.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With