DEV Community πŸ‘©β€πŸ’»πŸ‘¨β€πŸ’»

DEV Community πŸ‘©β€πŸ’»πŸ‘¨β€πŸ’» is a community of 964,423 amazing developers

We're a place where coders share, stay up-to-date and grow their careers.

Create account Log in
Akshay
Akshay

Posted on

Installing MariaDB inside a container

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
Enter fullscreen mode Exit fullscreen mode

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 &

Enter fullscreen mode Exit fullscreen mode

We added these lines to our Dockerfile and every time sql-server was started during the boot up.

Top comments (0)

🌚 Friends don't let friends browse without dark mode.

Sorry, it's true.