How to Install MariaDB with Docker

install mariadb docker

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.


Installing MariaDB with Docker

  1. 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.

  2. 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
  3. Once the installation is complete, you should be seeing an output as follow:
    Status: Downloaded newer image for mariadb:latest
  4. Finally, run the following command to confirm that MariaDB is running:
    docker ps
  5. You should now see an output similar to the following:
    77fabf6a4368 mariadb:latest "docker-entrypoint.s…" About a minute ago Up About a minute 3306/tcp containerdb


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

Related Post