1.启动命令
docker run --name mysql-server -t \
-e MYSQL_DATABASE="zabbix" \
-e MYSQL_USER="zabbix" \
-e MYSQL_PASSWORD="zabbix" \
-e MYSQL_ROOT_PASSWORD="123456" \
-d mysql:8.0 \
--restart unless-stopped \
--character-set-server=utf8 --collation-server=utf8_bin \
--default-authentication-plugin=mysql_native_password
2.查看报错日志
2021-01-16 03:33:39+00:00 [Note] [Entrypoint]: Entrypoint script for MySQL Server 8.0.22-1debian10 started.
2021-01-16 03:33:39+00:00 [Note] [Entrypoint]: Switching to dedicated user 'mysql'
2021-01-16 03:33:39+00:00 [Note] [Entrypoint]: Entrypoint script for MySQL Server 8.0.22-1debian10 started.
2021-01-16 03:33:39+00:00 [Note] [Entrypoint]: Initializing database files
2021-01-16T03:33:39.939639Z 0 [System] [MY-013169] [Server] /usr/sbin/mysqld (mysqld 8.0.22) initializing of server in progress as process 42
2021-01-16T03:33:39.940557Z 0 [Warning] [MY-013242] [Server] --character-set-server: 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous.
2021-01-16T03:33:39.940566Z 0 [Warning] [MY-013244] [Server] --collation-server: 'utf8_bin' is a collation of the deprecated character set UTF8MB3. Please consider using UTF8MB4 with an appropriate collation instead.
2021-01-16T03:33:39.946285Z 1 [System] [MY-013576] [InnoDB] InnoDB initialization has started.
2021-01-16T03:33:41.145940Z 1 [System] [MY-013577] [InnoDB] InnoDB initialization has ended.
2021-01-16T03:33:43.036463Z 0 [ERROR] [MY-000068] [Server] unknown option '--restart'.
2021-01-16T03:33:43.036849Z 0 [ERROR] [MY-013236] [Server] The designated data directory /var/lib/mysql/ is unusable. You can remove all files that the server added to it.
2021-01-16T03:33:43.037485Z 0 [ERROR] [MY-010119] [Server] Aborting
2021-01-16T03:33:45.836292Z 0 [System] [MY-010910] [Server] /usr/sbin/mysqld: Shutdown complete (mysqld 8.0.22) MySQL Community Server - GPL.
3.解决方案
把 --restart unless-stopped 参数放到镜像名字前面
正确启动命令
docker run --name mysql-server -t \
-e MYSQL_DATABASE="zabbix" \
-e MYSQL_USER="zabbix" \
-e MYSQL_PASSWORD="zabbix" \
-e MYSQL_ROOT_PASSWORD="123456" \
--restart unless-stopped \
-d mysql:8.0 \
--character-set-server=utf8 --collation-server=utf8_bin \
--default-authentication-plugin=mysql_native_password
解决掉了!!!