Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

passing --socket fails to initialize database #238

Closed
alvinr opened this issue Nov 21, 2016 · 2 comments
Closed

passing --socket fails to initialize database #238

alvinr opened this issue Nov 21, 2016 · 2 comments

Comments

@alvinr
Copy link

alvinr commented Nov 21, 2016

Problem

This seems to be a generic problem in the MySQL and MariaDB images. If --socket is passed when the container is created then the database fails to initialize, for example

docker run -d -e MYSQL_ROOT_PASSWORD=foo mysql:5.6 --socket=/tmp/mysql.sock

The problem resides at round line 70 of docker-entrypoint.sh

mysql=( mysql --protocol=socket -uroot -hlocalhost)

This code will assume the default location of the socket file (e.g. /var/run/mysqld/mysqld.sock), and does not take into account the location specified in the command line.

Solution

Ensure that any value from the command line is reflected in all potential uses of the mysql command.

@ltangvald
Copy link
Collaborator

A better solution might be to override the user's socket parameter when the server is started for init:

In general we pass any parameters set on the command line to the server, but not all server options are valid for the client, so we'd have to start filtering out options.

Since this client call is used to connect to the temporary server (started with --skip-networking) that is only used for database and user config, it doesn't need to use the socket location specified by the user.

@ltangvald
Copy link
Collaborator

Heh, I was confused about why this worked on 5.5. Checked the image and saw it doesn't have the socket path specified in any config file. From the docs: «The default location for the Unix socket file that the server uses for communication with local clients is /tmp/mysql.sock»

ltangvald added a commit to mysql/mysql-docker that referenced this issue Nov 22, 2016
During container init, we start both server and client temporarily,
for user admin etc. For the server we pass on any command line
arguments specified by the user, but for the client we don't. This
can cause an issue if the user specifies a different socket path,
since the client won't find it, causing init failure. Since the
socket location doesn't really matter for these temporary runs, we
hardcode it to /var/run/mysqld/mysqld.sock
Fixes issue docker-library#238
ebmeierj pushed a commit to firespring/mysql-no_volumes-docker that referenced this issue Jan 26, 2017
During container init, we start both server and client temporarily,
for user admin etc. For the server we pass on any command line
arguments specified by the user, but for the client we don't. This
can cause an issue if the user specifies a different socket path,
since the client won't find it, causing init failure. Since the
socket location doesn't really matter for these temporary runs, we
hardcode it to /var/run/mysqld/mysqld.sock
Fixes issue docker-library#238
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants