1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

【M1 mac】docker-composeでMySQLを使用した時のエラー解消法

Last updated at Posted at 2021-06-06

Laravelのwebアプリ作成のためにdocker-composeで環境構築をしており、MySQLを使用しようとしたらエラーが発生しました。
無事にエラーを解消できたので、エラー解消方法についてメモします。

開発環境

M1 mac使用
docker-compose version'3'
MySQL '5.7'

docker-compose.ymlの記載内容

docker-compose.ymlには以下のような内容で記載していました。

version: '3'
services:
  web:
      〜中略〜
  app:
      〜中略〜
  mysql:
    image: mysql:5.7
    environment:
      MYSQL_DATABASE: sample
      MYSQL_USER: user
      MYSQL_PASSWORD: password
      MYSQL_ROOT_PASSWORD: password
    ports:
      - "3306:3306"
    volumes:
      - mysql-data:/var/lib/mysql
volumes:
  mysql-data:

発生したエラー

上記の内容の通り、docker-composeでMySQLを使用したところ以下のようなエラーが発生しました。

docker: no matching manifest for linux/arm64/v8 in the manifest list entries.

エラーの原因と解消方法

調べたところM1macを使用していると発生するエラーとのこと。
解決方法としてdocker-compose.ymlにplatform指定をすれば良いらしい。

version: '3'
services:
  web:
      〜中略〜
  app:
      〜中略〜
  mysql:
         platform: linux/x86_64 #M1 mac対応のためこのコードを追記
    image: mysql:5.7
    environment:
      MYSQL_DATABASE: sample
      MYSQL_USER: user
      MYSQL_PASSWORD: password
      MYSQL_ROOT_PASSWORD: password
    ports:
      - "3306:3306"
    volumes:
      - mysql-data:/var/lib/mysql
volumes:
  mysql-data:

これで無事にdocker-composeでMySQLを使用することができました!!

1
0
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
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?