简体   繁体   中英

Unable to run mysql container with different my.cnf

When i was trying to run mysql container with image mysql/mysql-server:5.7.17 with change my.cnf using runtime --volume option, i was getting the error message.

[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!

But when the same thing i tried with mysql:latest image, i was able to run this 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

my.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/

Kindly help me.. Why both images behavior is not same.

The error tells you that a directory does not exist. Have you tried removing that last line of my.cnf to check for that? It would be better to not override the whole configuration file, but only those settings that you really want to change. The official documentation at https://hub.docker.com/_/mysql points out:

Please inspect the relevant files and directories within the mysql image itself for more details.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM