diff --git a/5.7/Dockerfile.oracle b/5.7/Dockerfile.oracle index 0907775dc..861c2e585 100644 --- a/5.7/Dockerfile.oracle +++ b/5.7/Dockerfile.oracle @@ -78,6 +78,7 @@ RUN set -eux; \ grep -F 'socket=/var/lib/mysql/mysql.sock' /etc/my.cnf; \ sed -i 's!^socket=.*!socket=/var/run/mysqld/mysqld.sock!' /etc/my.cnf; \ grep -F 'socket=/var/run/mysqld/mysqld.sock' /etc/my.cnf; \ + { echo '[client]'; echo 'socket=/var/run/mysqld/mysqld.sock'; } >> /etc/my.cnf; \ \ # make sure users dumping files in "/etc/mysql/conf.d" still works ! grep -F '!includedir' /etc/my.cnf; \ diff --git a/5.7/docker-entrypoint.sh b/5.7/docker-entrypoint.sh index 74d810080..ba9c3ce51 100755 --- a/5.7/docker-entrypoint.sh +++ b/5.7/docker-entrypoint.sh @@ -104,6 +104,18 @@ mysql_get_config() { # match "datadir /some/path with/spaces in/it here" but not "--xyz=abc\n datadir (xyz)" } +# Ensure that the package default socket can also be used +# since rpm packages are compiled with a different socket location +# and "mysqlsh --mysql" doesn't read the [client] config +# related to https://github.com/docker-library/mysql/issues/829 +mysql_socket_fix() { + local defaultSocket + defaultSocket="$(mysql_get_config 'socket' mysqld --no-defaults)" + if [ "$defaultSocket" != "$SOCKET" ]; then + ln -sfTv "$SOCKET" "$defaultSocket" || : + fi +} + # Do a temporary startup of the MySQL server, for init purposes docker_temp_server_start() { if [ "${MYSQL_MAJOR}" = '5.7' ]; then @@ -366,6 +378,7 @@ _main() { docker_temp_server_start "$@" mysql_note "Temporary server started." + mysql_socket_fix docker_setup_db docker_process_init_files /docker-entrypoint-initdb.d/* @@ -378,6 +391,8 @@ _main() { echo mysql_note "MySQL init process done. Ready for start up." echo + else + mysql_socket_fix fi fi exec "$@" diff --git a/8.0/Dockerfile.oracle b/8.0/Dockerfile.oracle index 36be9f734..7f2458089 100644 --- a/8.0/Dockerfile.oracle +++ b/8.0/Dockerfile.oracle @@ -80,6 +80,7 @@ RUN set -eux; \ grep -F 'socket=/var/lib/mysql/mysql.sock' /etc/my.cnf; \ sed -i 's!^socket=.*!socket=/var/run/mysqld/mysqld.sock!' /etc/my.cnf; \ grep -F 'socket=/var/run/mysqld/mysqld.sock' /etc/my.cnf; \ + { echo '[client]'; echo 'socket=/var/run/mysqld/mysqld.sock'; } >> /etc/my.cnf; \ \ # make sure users dumping files in "/etc/mysql/conf.d" still works ! grep -F '!includedir' /etc/my.cnf; \ diff --git a/8.0/docker-entrypoint.sh b/8.0/docker-entrypoint.sh index 74d810080..ba9c3ce51 100755 --- a/8.0/docker-entrypoint.sh +++ b/8.0/docker-entrypoint.sh @@ -104,6 +104,18 @@ mysql_get_config() { # match "datadir /some/path with/spaces in/it here" but not "--xyz=abc\n datadir (xyz)" } +# Ensure that the package default socket can also be used +# since rpm packages are compiled with a different socket location +# and "mysqlsh --mysql" doesn't read the [client] config +# related to https://github.com/docker-library/mysql/issues/829 +mysql_socket_fix() { + local defaultSocket + defaultSocket="$(mysql_get_config 'socket' mysqld --no-defaults)" + if [ "$defaultSocket" != "$SOCKET" ]; then + ln -sfTv "$SOCKET" "$defaultSocket" || : + fi +} + # Do a temporary startup of the MySQL server, for init purposes docker_temp_server_start() { if [ "${MYSQL_MAJOR}" = '5.7' ]; then @@ -366,6 +378,7 @@ _main() { docker_temp_server_start "$@" mysql_note "Temporary server started." + mysql_socket_fix docker_setup_db docker_process_init_files /docker-entrypoint-initdb.d/* @@ -378,6 +391,8 @@ _main() { echo mysql_note "MySQL init process done. Ready for start up." echo + else + mysql_socket_fix fi fi exec "$@" diff --git a/template/Dockerfile.oracle b/template/Dockerfile.oracle index 2077c4f75..d38873935 100644 --- a/template/Dockerfile.oracle +++ b/template/Dockerfile.oracle @@ -77,6 +77,7 @@ RUN set -eux; \ grep -F 'socket=/var/lib/mysql/mysql.sock' /etc/my.cnf; \ sed -i 's!^socket=.*!socket=/var/run/mysqld/mysqld.sock!' /etc/my.cnf; \ grep -F 'socket=/var/run/mysqld/mysqld.sock' /etc/my.cnf; \ + { echo '[client]'; echo 'socket=/var/run/mysqld/mysqld.sock'; } >> /etc/my.cnf; \ \ # make sure users dumping files in "/etc/mysql/conf.d" still works ! grep -F '!includedir' /etc/my.cnf; \ diff --git a/template/docker-entrypoint.sh b/template/docker-entrypoint.sh index 74d810080..ba9c3ce51 100755 --- a/template/docker-entrypoint.sh +++ b/template/docker-entrypoint.sh @@ -104,6 +104,18 @@ mysql_get_config() { # match "datadir /some/path with/spaces in/it here" but not "--xyz=abc\n datadir (xyz)" } +# Ensure that the package default socket can also be used +# since rpm packages are compiled with a different socket location +# and "mysqlsh --mysql" doesn't read the [client] config +# related to https://github.com/docker-library/mysql/issues/829 +mysql_socket_fix() { + local defaultSocket + defaultSocket="$(mysql_get_config 'socket' mysqld --no-defaults)" + if [ "$defaultSocket" != "$SOCKET" ]; then + ln -sfTv "$SOCKET" "$defaultSocket" || : + fi +} + # Do a temporary startup of the MySQL server, for init purposes docker_temp_server_start() { if [ "${MYSQL_MAJOR}" = '5.7' ]; then @@ -366,6 +378,7 @@ _main() { docker_temp_server_start "$@" mysql_note "Temporary server started." + mysql_socket_fix docker_setup_db docker_process_init_files /docker-entrypoint-initdb.d/* @@ -378,6 +391,8 @@ _main() { echo mysql_note "MySQL init process done. Ready for start up." echo + else + mysql_socket_fix fi fi exec "$@"