Installing MariaDB inside a container
Akshay
Posted on September 4, 2021
We had a requirement of installing MariaDB to an existing docker image because the test cases had to run within the same image and the rails framework needs a test database to run the tests.
After installing the MariaDB using yum, we tried to start the sql server within the container, it threw
ERROR 2002 (HY000): Cant connect to local MySQL server through socket /var/lib/mysql/mysql.sock
Excerpts of step from the article:
start the service manually and
ensure that you have started it such that it will stay in the foreground (because a Docker container exits when the foreground process exits or puts itself into the background).
Inside a docker container, nothing will run by default. The following code when executed within the container will start the server.
/usr/libexec/mariadb-prepare-db-dir mariadb.service
/usr/bin/mysqld_safe --basedir=/usr &
We added these lines to our Dockerfile and every time sql-server was started during the boot up.
Posted on September 4, 2021
Join Our Newsletter. No Spam, Only the good stuff.
Sign up to receive the latest update from our blog.