1

I encountered an issue when running the docker container. An error log was generated as below:

[Error] mysqld : unknown variable “wait_timeout = 288000”.

I wanted to test some docker container features. So, I opened the docker bash and entered the directory /etc/mysql/my.cnf. And I added the variable “wait_timeout = 288000” below [mysqld] option.

However, after rebooting, when I ran the container, it exited immediately with status code (1). I knew that the error was caused by the variable I just added. So, I wanted to delete the variable, but now the docker container bash won’t open. Is there any way that I can delete the variable “wait_timeout” in this case? If there isn’t, could you recommend other methods for troubleshooting? Thanks for checking the issue.

Ed Lee
  • 11
  • 2

1 Answers1

0

Delete and recreate the container, and it will start fresh from a clean container filesystem.

That is probably also a better way to modify the database configuration (if you do, in fact, need a custom my.cnf). You can bind-mount a directory of configuration files into the container at startup time:

docker run -d -p 3306:3306 --name mysql \
  -v $PWD/mysql-conf:/etc/mysql/conf.d \
  mysql:8

Then when the configuration changes, you can delete and recreate this container:

docker stop mysql
docker rm mysql
docker run -d -p 3306:3306 ... mysql:8 # as above

(See "Using a custom MySQL configuration file" in the Docker Hub mysql image page for more information.)

Deleting and recreating Docker containers is very routine, and one of the benefits is that when a new container starts, it always has a "clean" filesystem. This particular setup also makes sure the modified configuration file is stored outside the container, so if you are forced to recreate the container (to upgrade MySQL to get a critical security fix, for example) it's something you're used to doing and you won't lose data or settings.

David Maze
  • 130,717
  • 29
  • 175
  • 215