Get Started with MariaDB using Docker in 3 Steps


There’s no question that MariaDB has become one of the most popular databases of choice for developers over the past decade. While many technologists have likely gravitated to it as a solution due to its open source roots and that it’s rooted in the relational database world, that really only begins to scratch the surface of what MariaDB has to offer.

But that’s not what this article is about. There is plenty of information between the products page, official documentation and even the MariaDB Developer Hub that can help you dive deeper into the vast array of features and functionality MariaDB has to offer.

Instead, in this article, I want to focus on the quickest way you can go from nothing to having a local instance of a MariaDB database up, running and ready to use so you can start checking things out, using a Docker Container, for yourself.

OK, let’s get into it.

Step 1 – Install Docker

Unless you’ve been living under a rock for the past several years I know you’ve at least heard of Docker, or, at the very least, the concept of containerization. And, if not, no biggie check this out if you’re curious.

To start using Docker on your local machine you’re going to need to download and install Docker Desktop.

Step 2 – Create MariaDB Docker Container

Once you’ve successfully installed Docker on your machine you’re ready to pull the MariaDB image and spin up a container (which will contain a MariaDB database instance).

For this you’re going to use the Official MariaDB Docker Image hosted at

Open up a new terminal window and execute the following command.

> docker run -p  --name mdb -e MARIADB_ROOT_PASSWORD=Password123! -d mariadb:latest

The previous statement will pull down the latest version of the Official MariaDB image and spin up a new container on localhost (, exposing port 3306 and allow you to connect using the root user with password Password123!

Hint:  I guess this is something like Step 2-b, but you can confirm that the docker run command has successfully pulled the MariaDB Image and spun up a container by executing docker ps, which will show you all of the containers currently running.

Step 3 – Connect to MariaDB

Lastly, you don’t need to install anything else to start using MariaDB. Now, while you certainly can use other types of clients or tools to connect to and communicate with a MariaDB database, for this brief walkthrough you can just use the MariaDB command-line client that’s included within the MariaDB Docker container.

Execute the following to connect to MariaDB using the command-line client:

> docker exec -it mdb mariadb --user root -pPassword123!

Which should result in something like the following:

Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 4
Server version: 10.6.3-MariaDB-1:10.6.3+maria~focal binary distribution
Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
MariaDB [(none)]> 

And that’s it! That’s all you need to connect to and start using (querying) MariaDB.

MariaDB [(none)]> CREATE DATABASE mariadb_is_awesome;

Learn more

If you’d like to learn even more about what’s possible with Docker and MariaDB, or about the many other MariaDB features and capabilities, be sure to check out the Developer Hub and our new Developer Code Central GitHub organization.

You can also dive even deeper into MariaDB capabilities in the official documentation.

And, as always, we’d be nothing without our awesome community! If you’d like to help contribute you can find us on GitHub, send feedback directly to us at [email protected], or join the conversation in the new MariaDB Community Slack!

Happy coding, friends!