Mysql 为什么我可以用volumes参数启动容器

Mysql 为什么我可以用volumes参数启动容器,mysql,docker,docker-compose,Mysql,Docker,Docker Compose,我的问题是,当我在没有指定volumes参数的情况下启动映像时,一切都正常。但是当我指定容器时,不能以以下错误开始 这是我的docker compose: version: '3.7' # Use root/example as user/password credentials services: db: image: mysql:8.0 command: --default-authentication-plugin=mysql_native_password

我的问题是,当我在没有指定volumes参数的情况下启动映像时,一切都正常。但是当我指定容器时,不能以以下错误开始

这是我的docker compose:

version: '3.7'
# Use root/example as user/password credentials
services:

  db:
    image: mysql:8.0
    command: --default-authentication-plugin=mysql_native_password
    restart: always
    environment:
      MYSQL_ROOT_PASSWORD: 123zemtsov321
    volumes:
      - ./docker/database/mysql01:/var/lib/mysql

  adminer:
    image: adminer
    restart: always
    ports:
      - 6080:8080

db_1       | mysqld: Table 'mysql.plugin' doesn't exist
db_1       | 2019-09-05T10:16:32.860733Z 0 [Warning] [MY-011070] [Server] 'Disabling symbolic links using --skip-symbolic-links (or equivalent) is the default. Consider not using this option as it' is deprecated and will be removed in a future release.
db_1       | 2019-09-05T10:16:32.861130Z 0 [System] [MY-010116] [Server] /usr/sbin/mysqld (mysqld 8.0.17) starting as process 1
db_1       | 2019-09-05T10:16:34.628973Z 0 [ERROR] [MY-010735] [Server] Could not open the mysql.plugin table. Please perform the MySQL upgrade procedure.
db_1       | 2019-09-05T10:16:34.737017Z 0 [Warning] [MY-010015] [Repl] Gtid table is not ready to be used. Table 'mysql.gtid_executed' cannot be opened.
db_1       | 2019-09-05T10:16:34.788763Z 0 [Warning] [MY-000054] [Server] World-writable config file './auto.cnf' is ignored.
db_1       | 2019-09-05T10:16:34.789050Z 0 [Warning] [MY-010107] [Server] World-writable config file './auto.cnf' has been removed.
db_1       | 2019-09-05T10:16:34.789371Z 0 [Warning] [MY-010075] [Server] No existing UUID has been found, so we assume that this is the first time that this server has been started. Generating a new UUID: 3d261de8-cfc6-11e9-a284-0242ac120003.
db_1       | 2019-09-05T10:16:34.922344Z 0 [Warning] [MY-010015] [Repl] Gtid table is not ready to be used. Table 'mysql.gtid_executed' cannot be opened.
db_1       | 2019-09-05T10:16:34.958036Z 0 [Warning] [MY-010069] [Server] Failed to set up SSL because of the following SSL library error: SSL context is not usable without certificate and private key
db_1       | 2019-09-05T10:16:34.958975Z 0 [Warning] [MY-010284] [Server] RSA public key file not found: /var/lib/mysql//public_key.pem. Some authentication plugins will not work.
db_1       | 2019-09-05T10:16:34.959371Z 0 [Warning] [MY-010284] [Server] RSA public key file not found: /var/lib/mysql//public_key.pem. Some authentication plugins will not work.
db_1       | 2019-09-05T10:16:34.964792Z 0 [Warning] [MY-011810] [Server] Insecure configuration for --pid-file: Location '/var/run/mysqld' in the path is accessible to all OS users. Consider choosing a different directory.
db_1       | 2019-09-05T10:16:34.965651Z 0 [Warning] [MY-010441] [Server] Failed to open optimizer cost constant tables
db_1       | 2019-09-05T10:16:34.966395Z 0 [ERROR] [MY-013129] [Server] A message intended for a client cannot be sent there as no client-session is attached. Therefore, we're sending the information to the error-log instead: MY-001146 - Table 'mysql.component' doesn't exist
db_1       | 2019-09-05T10:16:34.966438Z 0 [Warning] [MY-013129] [Server] A message intended for a client cannot be sent there as no client-session is attached. Therefore, we're sending the information to the error-log instead: MY-003543 - The mysql.component table is missing or has an incorrect definition.
db_1       | 2019-09-05T10:16:34.968178Z 0 [ERROR] [MY-010326] [Server] Fatal error: Can't open and lock privilege tables: Table 'mysql.user' doesn't exist
db_1       | 2019-09-05T10:16:34.968332Z 0 [ERROR] [MY-010952] [Server] The privilege system failed to initialize correctly. For complete instructions on how to upgrade MySQL to a new version please see the 'Upgrading MySQL' section from the MySQL manual.
db_1       | 2019-09-05T10:16:34.969207Z 0 [ERROR] [MY-010119] [Server] Aborting
db_1       | 2019-09-05T10:16:35.815514Z 0 [System] [MY-010910] [Server] /usr/sbin/mysqld: Shutdown complete (mysqld 8.0.17)  MySQL Community Server - GPL.
work_db_1 exited with code 1

为什么我会发现这是错误????

它看起来可能是由当前存在的任何东西造成的。/docker/database/mysql01,当您启动它时。我将通过将安装到文件系统上的不同位置来开始故障排除,以查看新的启动是否解决了问题,或者深入研究现有内容以找出问题所在。这篇文章虽然很老,但它似乎解决了一些类似于您在自己的情况下看到的错误:

/docker/database/mysql01中有什么?您是否从另一个不是使用此docker配置创建的mysql实例复制了它?我会尝试删除这些内容,看看你在启动时是否会遇到同样的错误。