LoginSignup
1
1

More than 1 year has passed since last update.

docker-compose を用いて M1 Mac 等 ARM 系 CPU で動作する Apache, MariaDB, PHP の開発環境構築

Posted at

目的

M1 Mac で PHP, MySQL もしくは MariaDB が動作する開発環境を作成する。
但し下記を満たすこと。
1. Mac 環境を汚さないように仮想環境を用いる
2. 動作速度が許容範囲内

結果

試行錯誤の結果、仮想マシン環境ソフトウェア Parallels Desktop で Fedora 35 Server の仮想環境を構築し、https://github.com/kotanbo/docker-lamp-for-arm を docker-compose で起動するようにした。

理想としては Docker Desktop で構築したかったが、動作速度が遅く許容できなかったため、Linux の仮想環境内で Docker を利用することとした。

当初は MySQL で構築していたが、ある程度大きいダンプファイルをインポートすると下記エラーとなって落ちるので MariaDB を選択した。

2022-01-16T03:04:41.549704+09:00 0 [ERROR] [MY-013183] [InnoDB] Assertion failure: ddl0buffer.cc:204:ptr < bounds.second thread 281470673346800
InnoDB: We intentionally generate a memory trap.
InnoDB: Submit a detailed bug report to http://bugs.mysql.com.
InnoDB: If you get repeated assertion failures or crashes, even
InnoDB: immediately after the mysqld startup, there may be
InnoDB: corruption in the InnoDB tablespace. Please refer to
InnoDB: http://dev.mysql.com/doc/refman/8.0/en/forcing-innodb-recovery.html
InnoDB: about forcing recovery.
18:04:41 UTC - mysqld got signal 6 ;
Most likely, you have hit a bug, but this error can also be caused by malfunctioning hardware.
Thread pointer: 0x0
Attempting backtrace. You can use the following information to find out
where mysqld died. If you see no messages after this, something went
terribly wrong...

構築手順

Fedora 35 Server 構築

  1. https://getfedora.org/ja/server/download/ から aarch64 イメージをダウンロード
  2. Parallels Desktop を使ってイメージから Fedora 35 Server をインストール

Parallels Tools インストール

Mac と Fedora 35 Server 間でファイル共有するためにインストール
参考:https://download.parallels.com/desktop/v17/docs/ja_JP/Parallels%20Desktop%20User's%20Guide/32791.htm

  1. Parallels のメニュー "処理" をクリックして "Parallels Tools のインストール" を選択
  2. Fedora 35 Server に SSH 接続
  3. Parallels Tools インストールディスクイメージをマウントしてインストール
$ cd /media/
$ mkdir cdrom
$ mount -o exec /dev/cdrom /media/cdrom
$ cd cdrom/
$ ./install

Docker, docker-compose 構築

参考:https://matsuand.github.io/docs.docker.jp.onthefly/engine/install/fedora/

  1. Fedora 35 Server に SSH 接続
  2. Docker, docker-compose インストール
$ dnf install dnf-plugins-core
$ dnf config-manager --add-repo https://download.docker.com/linux/fedora/docker-ce.repo
$ dnf install docker-ce docker-ce-cli containerd.io
$ systemctl enable docker
$ systemctl start docker
$ dnf install docker-compose
$ chmod +x /usr/bin/docker-compose

ソース共有

  1. https://github.com/kotanbo/docker-lamp-for-arm をクローン
  2. Parallels のメニュー "デバイス" => "共有" => "構成" を選択
  3. クローンしたプロジェクトを共有
    Fedora 35 Server 内の "/media/psf/" に共有される

Apache, MariaDB, PHP 起動

https://github.com/kotanbo/docker-lamp-for-arm/blob/main/README.md の "Usage" を参照

1
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
1