簡體   English   中英

無法使用不同的 my.cnf 運行 mysql 容器

[英]Unable to run mysql container with different my.cnf

當我嘗試使用運行時 --volume 選項更改 my.cnf 並使用圖像 mysql/mysql-server:5.7.17 運行 mysql 容器時,我收到了錯誤消息。

[myhome tmp]# docker run -it -v /tmp/mysql/my.cnf:/etc/mysql/my.cnf  -e MYSQL_ROOT_PASSWORD=123456 mysql/mysql-server:5.7.17 
error: could not run mysql. This could be caused by a misconfigured my.cnf
mysqld: Can't read dir of '/etc/mysql/conf.d/' (Errcode: 2 - No such file or directory)
mysqld: [ERROR] Fatal error in defaults handling. Program aborted!

但是當我用 mysql:latest image 嘗試同樣的事情時,我能夠運行這個圖像:

[myhome tmp]# docker run -it -v /tmp/mysql/my.cnf:/etc/mysql/my.cnf  -e MYSQL_ROOT_PASSWORD=123456 mysql
2020-04-11 11:54:21+00:00 [Note] [Entrypoint]: Entrypoint script for MySQL Server 8.0.19-1debian10 started.
2020-04-11 11:54:21+00:00 [Note] [Entrypoint]: Switching to dedicated user 'mysql'
2020-04-11 11:54:21+00:00 [Note] [Entrypoint]: Entrypoint script for MySQL Server 8.0.19-1debian10 started.
2020-04-11 11:54:21+00:00 [Note] [Entrypoint]: Initializing database files
2020-04-11T11:54:21.949032Z 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.
2020-04-11T11:54:21.949185Z 0 [System] [MY-013169] [Server] /usr/sbin/mysqld (mysqld 8.0.19) initializing of server in progress as process 40
2020-04-11T11:54:27.882357Z 5 [Warning] [MY-010453] [Server] root@localhost is created with an empty password ! Please consider switching off the --initialize-insecure option.
2020-04-11 11:54:32+00:00 [Note] [Entrypoint]: Database files initialized
2020-04-11 11:54:32+00:00 [Note] [Entrypoint]: Starting temporary server
mysqld will log errors to /var/lib/mysql/fc326f61d85d.err
mysqld is running as pid 92
2020-04-11 11:54:33+00:00 [Note] [Entrypoint]: Temporary server started.
Warning: Unable to load '/usr/share/zoneinfo/iso3166.tab' as time zone. Skipping it.
Warning: Unable to load '/usr/share/zoneinfo/leap-seconds.list' as time zone. Skipping it.
Warning: Unable to load '/usr/share/zoneinfo/zone.tab' as time zone. Skipping it.
Warning: Unable to load '/usr/share/zoneinfo/zone1970.tab' as time zone. Skipping it.

2020-04-11 11:54:38+00:00 [Note] [Entrypoint]: Stopping temporary server
2020-04-11 11:54:41+00:00 [Note] [Entrypoint]: Temporary server stopped

2020-04-11 11:54:41+00:00 [Note] [Entrypoint]: MySQL init process done. Ready for start up.

2020-04-11T11:54:41.972267Z 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.
2020-04-11T11:54:41.972310Z 0 [Warning] [MY-010097] [Server] Insecure configuration for --secure-file-priv: Current value does not restrict location of generated files. Consider setting it to a valid, non-empty path.
2020-04-11T11:54:41.972376Z 0 [System] [MY-010116] [Server] /usr/sbin/mysqld (mysqld 8.0.19) starting as process 1
2020-04-11T11:54:42.834746Z 0 [Warning] [MY-010068] [Server] CA certificate ca.pem is self signed.
2020-04-11T11:54:42.838151Z 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.
2020-04-11T11:54:42.872638Z 0 [System] [MY-010931] [Server] /usr/sbin/mysqld: ready for connections. Version: '8.0.19'  socket: '/var/run/mysqld/mysqld.sock'  port: 3306  MySQL Community Server - GPL.
2020-04-11T11:54:42.992548Z 0 [System] [MY-011323] [Server] X Plugin ready for connections. Socket: '/var/run/mysqld/mysqlx.sock' bind-address: '::' port: 33060


mbind: Operation not permitted

我的.cnf

[mysqld]
pid-file=/var/run/mysqld/mysqld.pid
socket=/var/run/mysqld/mysqld.sock
datadir=/var/lib/mysql
secure-file-priv=""
server-id=100
user=mysql
symbolic-links=0
!includedir /etc/mysql/conf.d/

請幫助我..為什么兩個圖像的行為都不一樣。

該錯誤告訴您目錄不存在。 您是否嘗試過刪除my.cnf的最后一行來檢查它? 最好不要覆蓋整個配置文件,而只覆蓋您真正想要更改的那些設置。 https://hub.docker.com/_/mysql的官方文檔指出:

請檢查 mysql 映像本身中的相關文件和目錄以獲取更多詳細信息。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM