Docker-compse で MySQL を単体で動かす
Tags: docker
Published: 2021-12-05 14:37:55


## brew cask では M1 の Docker App は入らない

https://kunolog.com/docker-desktop-m1/

この記事の通りに `brew install --cask docker` をやると

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/37t7fjetb22gshna8owa.png)
 
M1 に対応しない Docker が入ってしまう

## Docker.com から Apple Chip 用の Docker を入れる

https://docs.docker.com/desktop/mac/install/

公式サイトに

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/n5476u8gihyouvwtqrve.png)

Appleの m1 チップ用のインストールボタンがある。

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/vhschm9r3p0y614rzaqj.png)

インストールできた！
見やすい！

```
docker-compose --version
docker-compose version 1.29.2, build 5becea4c
```

docker-compose も入っていた

## 動作させる

`docker-compose.yml` を作成する

```
version: "3.7"
services:
  db:
    image: mysql:latest
    environment:
      MYSQL_ALLOW_EMPTY_PASSWORD: "yes"
```

mysql だけ動かす

```
docker-compose up
Creating network "docker-mysql_default" with the default driver
Pulling db (mysql:latest)...
latest: Pulling from library/mysql
ERROR: no matching manifest for linux/arm64/v8 in the manifest list entries
```

普通のだとむり

https://stackoverflow.com/a/65592942

```
platform: linux/x86_64
```

プラットフォームを指定すれば arm 用のが使える

```
Attaching to docker-mysql_db_1
db_1  | 2021-10-17 17:05:28+00:00 [Note] [Entrypoint]: Entrypoint script for MySQL Server 8.0.26-1debian10 started.
db_1  | 2021-10-17 17:05:29+00:00 [Note] [Entrypoint]: Switching to dedicated user 'mysql'
db_1  | 2021-10-17 17:05:29+00:00 [Note] [Entrypoint]: Entrypoint script for MySQL Server 8.0.26-1debian10 started.
db_1  | 2021-10-17 17:05:29+00:00 [Note] [Entrypoint]: Initializing database files
db_1  | 2021-10-17T17:05:29.932099Z 0 [System] [MY-013169] [Server] /usr/sbin/mysqld (mysqld 8.0.26) initializing of server in progress as process 100
db_1  | 2021-10-17T17:05:30.017444Z 1 [System] [MY-013576] [InnoDB] InnoDB initialization has started.
db_1  | 2021-10-17T17:05:30.038544Z 1 [ERROR] [MY-012585] [InnoDB] Linux Native AIO interface is not supported on this platform. Please check your OS documentation and install appropriate b
inary of InnoDB.
db_1  | 2021-10-17T17:05:30.039290Z 1 [Warning] [MY-012654] [InnoDB] Linux Native AIO disabled.
db_1  | 2021-10-17T17:05:30.827103Z 1 [System] [MY-013577] [InnoDB] InnoDB initialization has ended.
db_1  | 2021-10-17T17:05:34.403943Z 0 [Warning] [MY-013746] [Server] A deprecated TLS version TLSv1 is enabled for channel mysql_main
db_1  | 2021-10-17T17:05:34.406790Z 0 [Warning] [MY-013746] [Server] A deprecated TLS version TLSv1.1 is enabled for channel mysql_main
db_1  | 2021-10-17T17:05:34.598348Z 6 [Warning] [MY-010453] [Server] root@localhost is created with an empty password ! Please consider switching off the --initialize-insecure option.
db_1  | 2021-10-17 17:05:40+00:00 [Note] [Entrypoint]: Database files initialized
db_1  | 2021-10-17 17:05:40+00:00 [Note] [Entrypoint]: Starting temporary server
db_1  | 2021-10-17T17:05:40.488893Z 0 [System] [MY-010116] [Server] /usr/sbin/mysqld (mysqld 8.0.26) starting as process 155
```

動いた

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/12nd8fcvu11o36yfjym8.png)

アプリでも確認できる！