Open4

M1 Mac の Docker Desktop のアプデを mysql で確かめる

odanodan

mysql:5.7 は ARM64 のコンテナイメージが提供されていないため、--platform linux/amd64 の指定が必須だった

指定しない場合

$ docker run --rm -it mysql:5.7
docker: no matching manifest for linux/arm64/v8 in the manifest list entries.
See 'docker run --help'.

指定した場合

$ docker run --rm -it --platform linux/amd64 mysql:5.7
2023-01-15 10:42:26+00:00 [Note] [Entrypoint]: Entrypoint script for MySQL Server 5.6.51-1debian9 started.
2023-01-15 10:42:26+00:00 [Note] [Entrypoint]: Switching to dedicated user 'mysql'
2023-01-15 10:42:26+00:00 [Note] [Entrypoint]: Entrypoint script for MySQL Server 5.6.51-1debian9 started.
2023-01-15 10:42:27+00:00 [ERROR] [Entrypoint]: Database is uninitialized and password option is not specified
    You need to specify one of the following:
    - MYSQL_ROOT_PASSWORD
    - MYSQL_ALLOW_EMPTY_PASSWORD
    - MYSQL_RANDOM_ROOT_PASSWORD
odanodan

しかし --platform linux/amd64 を指定して動くコンテナのバージョンは限られている。例えば Aurora MySQL と互換性のある 5.7.12--platform オプションを指定しても起動しない

$  docker run --rm -it --platform linux/amd64 mysql:5.7.12
runtime: failed to create new OS thread (have 2 already; errno=22)
fatal error: newosproc

runtime stack:
runtime.throw(0x524da0, 0x9)
	/usr/local/go/src/runtime/panic.go:527 +0x90
runtime.newosproc(0xc82002a000, 0xc820039fc0)
	/usr/local/go/src/runtime/os1_linux.go:150 +0x1ab
runtime.newm(0x555ce8, 0x0)
	/usr/local/go/src/runtime/proc1.go:1105 +0x130
runtime.main.func1()
	/usr/local/go/src/runtime/proc.go:48 +0x2c
runtime.systemstack(0x5c4300)
	/usr/local/go/src/runtime/asm_amd64.s:262 +0x79
runtime.mstart()
	/usr/local/go/src/runtime/proc1.go:674

goroutine 1 [running]:
runtime.systemstack_switch()
	/usr/local/go/src/runtime/asm_amd64.s:216 fp=0xc820024770 sp=0xc820024768
runtime.main()
	/usr/local/go/src/runtime/proc.go:49 +0x62 fp=0xc8200247c0 sp=0xc820024770
runtime.goexit()
	/usr/local/go/src/runtime/asm_amd64.s:1696 +0x1 fp=0xc8200247c8 sp=0xc8200247c0

https://docs.aws.amazon.com/AmazonRDS/latest/AuroraUserGuide/AuroraMySQL.Updates.Versions.html

odanodan

Use Rosetta for x86/amd64 emulation on Apple Silicon を有効化して試す

mysq:5.7 の場合

$ docker run --rm -it mysql:5.7
WARNING: The requested image's platform (linux/amd64) does not match the detected host platform (linux/arm64/v8) and no specific platform was requested
2023-01-15 10:55:49+00:00 [Note] [Entrypoint]: Entrypoint script for MySQL Server 5.7.40-1.el7 started.
2023-01-15 10:55:50+00:00 [Note] [Entrypoint]: Switching to dedicated user 'mysql'
2023-01-15 10:55:50+00:00 [Note] [Entrypoint]: Entrypoint script for MySQL Server 5.7.40-1.el7 started.
2023-01-15 10:55:50+00:00 [ERROR] [Entrypoint]: Database is uninitialized and password option is not specified
    You need to specify one of the following as an environment variable:
    - MYSQL_ROOT_PASSWORD
    - MYSQL_ALLOW_EMPTY_PASSWORD
    - MYSQL_RANDOM_ROOT_PASSWORD

mysq:5.7.12 の場合

$ docker run --rm -it mysql:5.7.12
WARNING: The requested image's platform (linux/amd64) does not match the detected host platform (linux/arm64/v8) and no specific platform was requested
error: database is uninitialized and password option is not specified
  You need to specify one of MYSQL_ROOT_PASSWORD, MYSQL_ALLOW_EMPTY_PASSWORD and MYSQL_RANDOM_ROOT_PASSWORD

どっちも動いてそう