YAML の書き方の問題ですね
command
はなるべくスペースごとに区切って配列として指定します:
yaml
1version: '3.1'
2services:
3 db:
4 image: mysql:5.7
5 command:
6 - mysqld
7 - --character-set-server=utf8
8 - --collation-server=utf8_unicode_ci
9 - --general-log=true
10 - --general-log-file=/var/log/mysql/general.log
11 environment:
12 - MYSQL_DATABASE=ogp
13 - MYSQL_ROOT_PASSWORD=pass
14 - MYSQL_USER=default
15 - MYSQL_PASSWORD=password
16 - TZ=Asia/Tokyo
17 ports:
18 - "3306:3306"
実行結果:
console
1$ docker-compose up
2Recreating test-docker-compose_db_1 ... done
3Attaching to test-docker-compose_db_1
4db_1 | 2020-07-17 10:44:53+09:00 [Note] [Entrypoint]: Entrypoint script for MySQL Server 5.7.29-1debian9 started.
5db_1 | 2020-07-17 10:44:53+09:00 [Note] [Entrypoint]: Switching to dedicated user 'mysql'
6db_1 | 2020-07-17 10:44:53+09:00 [Note] [Entrypoint]: Entrypoint script for MySQL Server 5.7.29-1debian9 started.
7db_1 | 2020-07-17T01:44:53.851732Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
8db_1 | 2020-07-17T01:44:53.853030Z 0 [Note] mysqld (mysqld 5.7.29-log) starting as process 1 ...
9db_1 | 2020-07-17T01:44:53.856421Z 0 [Note] InnoDB: PUNCH HOLE support available
10db_1 | 2020-07-17T01:44:53.856460Z 0 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins
11db_1 | 2020-07-17T01:44:53.856466Z 0 [Note] InnoDB: Uses event mutexes
12db_1 | 2020-07-17T01:44:53.856470Z 0 [Note] InnoDB: GCC builtin __atomic_thread_fence() is used for memory barrier
13db_1 | 2020-07-17T01:44:53.856473Z 0 [Note] InnoDB: Compressed tables use zlib 1.2.11
14db_1 | 2020-07-17T01:44:53.856477Z 0 [Note] InnoDB: Using Linux native AIO
15db_1 | 2020-07-17T01:44:53.856730Z 0 [Note] InnoDB: Number of pools: 1
16db_1 | 2020-07-17T01:44:53.856950Z 0 [Note] InnoDB: Using CPU crc32 instructions
17db_1 | 2020-07-17T01:44:53.858544Z 0 [Note] InnoDB: Initializing buffer pool, total size = 128M, instances = 1, chunk size = 128M
18db_1 | 2020-07-17T01:44:53.871744Z 0 [Note] InnoDB: Completed initialization of buffer pool
19db_1 | 2020-07-17T01:44:53.873885Z 0 [Note] InnoDB: If the mysqld execution user is authorized, page cleaner thread priority can be changed. See the man page of setpriority().
20db_1 | 2020-07-17T01:44:53.885417Z 0 [Note] InnoDB: Highest supported file format is Barracuda.
21db_1 | 2020-07-17T01:44:53.886555Z 0 [Note] InnoDB: Log scan progressed past the checkpoint lsn 12442650
22db_1 | 2020-07-17T01:44:53.886590Z 0 [Note] InnoDB: Doing recovery: scanned up to log sequence number 12442659
23db_1 | 2020-07-17T01:44:53.886596Z 0 [Note] InnoDB: Database was not shutdown normally!
24db_1 | 2020-07-17T01:44:53.886600Z 0 [Note] InnoDB: Starting crash recovery.
25db_1 | 2020-07-17T01:44:54.005416Z 0 [Note] InnoDB: Removed temporary tablespace data file: "ibtmp1"
26db_1 | 2020-07-17T01:44:54.005484Z 0 [Note] InnoDB: Creating shared tablespace for temporary tables
27db_1 | 2020-07-17T01:44:54.005552Z 0 [Note] InnoDB: Setting file './ibtmp1' size to 12 MB. Physically writing the file full; Please wait ...
28db_1 | 2020-07-17T01:44:54.027694Z 0 [Note] InnoDB: File './ibtmp1' size is now 12 MB.
29db_1 | 2020-07-17T01:44:54.028748Z 0 [Note] InnoDB: 96 redo rollback segment(s) found. 96 redo rollback segment(s) are active.
30db_1 | 2020-07-17T01:44:54.028786Z 0 [Note] InnoDB: 32 non-redo rollback segment(s) are active.
31db_1 | 2020-07-17T01:44:54.030044Z 0 [Note] InnoDB: 5.7.29 started; log sequence number 12442659
32db_1 | 2020-07-17T01:44:54.030525Z 0 [Note] Plugin 'FEDERATED' is disabled.
33db_1 | 2020-07-17T01:44:54.034114Z 0 [Note] InnoDB: Loading buffer pool(s) from /var/lib/mysql/ib_buffer_pool
34db_1 | 2020-07-17T01:44:54.036425Z 0 [Note] InnoDB: Buffer pool(s) load completed at 200717 10:44:54
35db_1 | 2020-07-17T01:44:54.038518Z 0 [Note] Found ca.pem, server-cert.pem and server-key.pem in data directory. Trying to enable SSL support using them.
36db_1 | 2020-07-17T01:44:54.038550Z 0 [Note] Skipping generation of SSL certificates as certificate files are present in data directory.
37db_1 | 2020-07-17T01:44:54.039165Z 0 [Warning] CA certificate ca.pem is self signed.
38db_1 | 2020-07-17T01:44:54.039217Z 0 [Note] Skipping generation of RSA key pair as key files are present in data directory.
39db_1 | 2020-07-17T01:44:54.039620Z 0 [Note] Server hostname (bind-address): '*'; port: 3306
40db_1 | 2020-07-17T01:44:54.039692Z 0 [Note] IPv6 is available.
41db_1 | 2020-07-17T01:44:54.039708Z 0 [Note] - '::' resolves to '::';
42db_1 | 2020-07-17T01:44:54.039736Z 0 [Note] Server socket created on IP: '::'.
43db_1 | 2020-07-17T01:44:54.050205Z 0 [Warning] Insecure configuration for --pid-file: Location '/var/run/mysqld' in the path is accessible to all OS users. Consider choosing a different directory.
44db_1 | 2020-07-17T01:44:54.058142Z 0 [Note] Event Scheduler: Loaded 0 events
45db_1 | 2020-07-17T01:44:54.058353Z 0 [Note] mysqld: ready for connections.
46db_1 | Version: '5.7.29-log' socket: '/var/run/mysqld/mysqld.sock' port: 3306 MySQL Community Server (GPL)
参考:
Compose file version 3 reference | Docker Documentation
Dockerfile reference | Docker Documentation
CMD ["executable","param1","param2"]
(exec form, this is the preferred form)