Find out how you can easily install MariaDB with Docker on your VPS cloud server. MariaDB is a popular relational database management system. Besides Docker, you may wish to check out how to install MariaDB directly onto your server. After all, you should take note that docker containers are immutable so they cannot be easily modified after start.
Summary
- You already have a Scalable VPS server on AlmaLinux 8
- Install Docker on AlmaLinux 8
- Setup MariaDB Docker Container
Installing MariaDB with Docker
- Let us first begin by learning the variables & parameters we are using:MariaDB Environment variables are marked in the Docker command with -e:-e MYSQL_ROOT_PASSWORD= Set your own password here.
-e MYSQL_DATABASE= Creates and names a new database e.g. wordpress.Docker parameters:
–name containerdb – Names the container.
-v “$PWD/database”:/var/lib/mysql – Creates a data directory linked to the container storage to ensure data persistence.
-d – Tells Docker to run the container in daemon.
mariadb:latest – Finally defines what to install and which version. - You may now begin with the following command:
docker run -e MYSQL_ROOT_PASSWORD=password-here -e MYSQL_DATABASE=database-name-here --name containerdb -v "$PWD/database":/var/lib/mysql -d mariadb:latest
- Once the installation is complete, you should be seeing an output as follow:
Status: Downloaded newer image for mariadb:latest 77fabf6a43680ecd15801d6cae67c57d9459ca1d5242099044d47e2b080b935f
- Finally, run the following command to confirm that MariaDB is running:
docker ps
- You should now see an output similar to the following:
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES 77fabf6a4368 mariadb:latest "docker-entrypoint.s…" About a minute ago Up About a minute 3306/tcp containerdb
Conclusions
This article shows you how you can easily install MariaDB with Docker. However, since docker is immutable, its data is not persistent. Hence, docker uses data volumes to remedy to this whereas MariaDB container uses a volume to preserve data