简体   繁体   English

Docker 镜像在 m1 处理器中运行

[英]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.我只能在我的 macbook air m1 中播放 docker 预览,我无法通过 docker-compose 文件运行版本 8.0.22 的 mysql 的图像。

docker-compose set docker-compose套装

The command i run is: docker-compose up -d mysql我运行的命令是: docker-compose up -d mysql

How can I solve this problem?我怎么解决这个问题?

M1 is ARMv8 (aarch64) architecture and majority of the images are X86 (amd64). M1 是 ARMv8 (aarch64) 架构,大部分镜像是 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.对于 Mac 版 Docker 的 ARMv8 版本,基于bitfmt允许从另一个架构运行容器的整个仿真过程仍然不稳定,因此您需要等待一些时间。

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). 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.您可以在标记为ARM64v8的 docker 集线器中找到很多可用的容器,因此这可以作为创建映像的良好起点。

I also struggled with X86 (amd64) images on my M1 Mac.我还在 M1 Mac 上处理了 X86 (amd64) 图像。 But in your particular case, I would recommend to simply use MariaDB (image mariadb).但在您的特定情况下,我建议您简单地使用 MariaDB(图像 mariadb)。 All things I tried so far, have been fully compatible with MySQL and MariaDB is available for ARM64.到目前为止,我尝试的所有东西都与 MySQL 完全兼容,并且 MariaDB 可用于 ARM64。

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:您可以在docker-compose文件中指定您的平台,因此在您的情况下,它看起来像:

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 和英特尔 Mac,此解决方案使 mysql 图像可用于两者。

You can also use mariadb as a drop-in replacement for mysql which supports M1 (arm64):您还可以使用mariadb作为支持 M1 (arm64) 的mysql的直接替代品:

    mysql:
        restart: unless-stopped
        image: mysql:5.7.14

Becomes:变成:

    mysql:
        restart: unless-stopped
        image: mariadb:10.2.41

Here's a list of the latest tags for MariaDB images:以下是 MariaDB 图像的最新标签列表:

https://hub.docker.com/_/mariadb?tab=tags https://hub.docker.com/_/mariadb?tab=tags

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM