1

I have used docker to setup mysql server taken from https://registry.hub.docker.com/_/mysql/ , I know that we can set up environment variables using several options while running an image as"-e , -env or --env-file" which works absolutely fine as I want. But now I want to edit my system variables for MySQL say "max_connections=300". Is there a way we can use these options to achieve this. I have tried using --env-file option to update system variables but no success :( would be really very helpful if anyone can give pointers on this.

Thanks, ~yash

2 Answers 2

3

From description of mysql docker container:

You can pass arbitrary command line options to the MySQL server by appending them to the run command:

docker run --name my-container-name -d mysql/mysql-server --option1=value --option2=value

In this case, the values of option1 and option2 will be passed directly to the server when it is started. The following command will for instance start your container with UTF-8 as the default setting for character set and collation for all databases in MySQL:

docker run --name my-container-name -d mysql/mysql-server --character-set-server=utf8 --collation-server=utf8_general_ci
Sign up to request clarification or add additional context in comments.

Comments

0

Have a look at, for example https://github.com/skarllot/docker-mysql/blob/master/assets/my.cnf.template for a specific value for max_connections, and for the Dockerfile https://github.com/skarllot/docker-mysql

1 Comment

Hi, Thank-you so much for response. what i understand from this image is that we are defining environment variables and their values inside docker image in "default.sh" file and for changing any value each time we will have to build a new container. Please correct me if I am wrong. What I want here is have a common docker image and while running it user can provide configurable parameters dynamically which will finally be used for MySQL server. Would be waiting for the response.....

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.