🐳

Mac M1 Docker で yum install がコケる

2022/03/09に公開

要約

docker-compose.yml で Platform を linux/x86_64 に指定すればOK

  • M1 と Intel で uname が異なる
  • uname が異なるとパッケージをPullするときのリポジトリが異なる
  • M1 の場合「aarch64 (ARM)」になるが、これが古いパッケージが提供されてない
  • \(^0^)/

ログ抜粋

コケてるとき

Platformを指定していないです。

docker-compose.yml

version: "3.9"

services:

  backend:
    container_name: hogefuga
    hostname: hogefuga.com
    privileged: true
    command:
      - /sbin/init
    build:
      context: .
      dockerfile: ./backend/Dockerfile

....

Dockerfile

FROM centos:7
USER root

RUN yum -y update
RUN yum -y install http://rpms.remirepo.net/enterprise/remi-release-7.rpm
RUN yum -y install --enablerepo=remi-php74 php php-devel php-mbstring php-mysql php-gd php-pdo php-pear php-process php-soap php-xml php-bcmath php-pecl-zip php-imagick httpd cronie-noanacron rsyslog

結果

yun install した途端に、Not Found Not Found Not Found Not Found .... <(^0^)>


....

Loaded plugins: fastestmirror, ovl
Loading mirror speeds from cached hostfile
epel/aarch64/metalink                                                                                                                                                   |  10 kB  00:00:00     
 * base: mirror.truenetwork.ru
 * epel: ftp.riken.jp
 * extras: mirror.truenetwork.ru
 * remi-php74: ftp.riken.jp
 * remi-safe: ftp.riken.jp
 * updates: mirror.truenetwork.ru
epel                                                                                                                                                                    | 5.4 kB  00:00:00     
http://ftp.riken.jp/Linux/remi/enterprise/7/php74/aarch64/repodata/repomd.xml: [Errno 14] HTTP Error 404 - Not Found
Trying other mirror.
To address this issue please refer to the below wiki article 

https://wiki.centos.org/yum-errors

If above article doesn't help to resolve this issue please use https://bugs.centos.org/.

https://remi.mirror.digitalpacific.com.au/enterprise/7/php74/aarch64/repodata/repomd.xml: [Errno 14] HTTPS Error 404 - Not Found
Trying other mirror.
http://rpms.remirepo.net/enterprise/7/php74/aarch64/repodata/repomd.xml: [Errno 14] HTTP Error 404 - Not Found
Trying other mirror.
https://mirrors.upr.edu/remi/enterprise/7/php74/aarch64/repodata/repomd.xml: [Errno 14] HTTPS Error 404 - Not Found
Trying other mirror.
https://mirrors.ptisp.pt/remi/enterprise/7/php74/aarch64/repodata/repomd.xml: [Errno 14] HTTPS Error 404 - Not Found
Trying other mirror.
http://mirror.hoster.kz/remi/enterprise/7/php74/aarch64/repodata/repomd.xml: [Errno 14] HTTP Error 404 - Not Found

...

改善ケース

docker-compose.yml

version: "3.9"

services:

  backend:
    container_name: hogefuga
    hostname: hogefuga.com
    privileged: true
    command:
      - /sbin/init
    build:
      context: .
      dockerfile: ./backend/Dockerfile

    # これを追加しました!
    platform: linux/x86_64

....

※ Dockerfile は編集していないです。

結果

.....

Loaded plugins: fastestmirror, ovl
Loading mirror speeds from cached hostfile
epel/x86_64/metalink                                                                                                                                                    | 5.1 kB  00:00:00     
 * base: ftp.riken.jp
 * epel: ftp.riken.jp
 * extras: ftp.riken.jp
 * remi-php74: ftp.riken.jp
 * remi-safe: ftp.riken.jp
 * updates: ftp.riken.jp
epel                                                                                                                                                                    | 4.7 kB  00:00:00     
remi-php74                                                                                                                                                              | 3.0 kB  00:00:00     
remi-safe                                                                                                                                                               | 3.0 kB  00:00:00     
(1/5): epel/x86_64/group_gz                                                                                                                                             |  96 kB  00:00:01     
(2/5): remi-php74/primary_db                                                                                                                                            | 254 kB  00:00:01     
(3/5): remi-safe/primary_db                                                                                                                                             | 2.1 MB  00:00:03     
(4/5): epel/x86_64/updateinfo                                                                                                                                           | 1.0 MB  00:00:08     
(5/5): epel/x86_64/primary_db                                                                                                                                           | 7.0 MB  00:00:17     
Package php-mysql is obsoleted by php-mysqlnd, trying to install php-mysqlnd-7.4.28-1.el7.remi.x86_64 instead
Resolving Dependencies
--> Running transaction check
---> Package cronie-noanacron.x86_64 0:1.4.11-24.el7_9 will be installed
--> Processing Dependency: cronie = 1.4.11-24.el7_9 for package: cronie-noanacron-1.4.11-24.el7_9.x86_64
--> Processing Dependency: crontabs for package: cronie-noanacron-1.4.11-24.el7_9.x86_64
---> Package httpd.x86_64 0:2.4.6-97.el7.centos.4 will be installed
--> Processing Dependency: httpd-tools = 2.4.6-97.el7.centos.4 for package: httpd-2.4.6-97.el7.centos.4.x86_64
--> Processing Dependency: system-logos >= 7.92.1-1 for package: httpd-2.4.6-97.el7.centos.4.x86_64

.....

  urw-base35-z003-fonts.noarch 0:20170801-10.el7             xorg-x11-font-utils.x86_64 1:7.5-21.el7                       xorg-x11-server-utils.x86_64 0:7.7-20.el7                         
  xz-devel.x86_64 0:5.2.2-1.el7                              zlib-devel.x86_64 0:1.2.7-19.el7_9                           

Dependency Updated:
  glibc.x86_64 0:2.17-325.el7_9          glibc-common.x86_64 0:2.17-325.el7_9  krb5-libs.x86_64 0:1.15.1-51.el7_9  libxml2.x86_64 0:2.9.1-6.el7_9.6  libxml2-python.x86_64 0:2.9.1-6.el7_9.6 
  openssl-libs.x86_64 1:1.0.2k-24.el7_9  zlib.x86_64 0:1.2.7-19.el7_9         

Complete!

ヤター! そもそもリポジトリのリストファイルのパスが変わるんですね。
M1の性能の代償としては、厄介なところ。。

Discussion