MySQL
SQL

MariaDB Docker: Server Setup Guide

intro

Find out everything you need to know about setting up a MariaDB Docker environment in this definitive guide.

Tools used in the tutorial
Tool Description Link
Dbvisualizer DBVISUALIZER
TOP RATED DATABASE MANAGEMENT TOOL AND SQL CLIENT
mariadb MARIADB
THE MARIADB DATABASE

These days, Docker is one of the leading platforms for building, shipping, and running various kinds of software appliances. Most of you reading this blog probably already have a good understanding of what Docker is, but for those who don’t, it’s essentially a platform aiming to help you build and run your applications through containers. Time to see how to get started with a MariaDB Docker integration!

What Is Docker?

As already mentioned above, Docker is a platform letting you build, test, and run software applications. For many, Docker is a brother to Kubernetes. While Kubernetes—or k8s—is used to manage and run many containers, Docker is used to deploy applications on a node. In other words, Docker excels at containerization.

Docker is perfect for software appliances that want to do as much as possible while using as little server resources as possible. However, the main use case of Docker is a little different. Since Docker can be run on any system that supports it, it solves many problems related to a piece of software working on a server A, but not server B and vice versa.

What Is MariaDB?

Many of you will be familiar with what MariaDB can offer to its users, as it’s a spin-off of a popular relational database management system called MySQL. In detail, MariaDB is a relational database management system based on MySQL. Or, rather, it’s MySQL on steroids enabling faster queries and more scalability. MariaDB has more storage engines than MySQL does, it offers different data types to choose from and is being actively developed by the original developers of MySQL.

MariaDB is a great choice for those who need high performance and wider choices compared to MySQL, but it does differ in some ways:

  1. MySQL is dual-licensed, while MariaDB operates on a GPL,
  2. MySQL offers fewer storage engines and data types to choose from,
  3. Most importantly, MariaDB provides the developers of MySQL to sell the ability to work with MySQL without making a product open-source (refer to point #1.)

Learn more in our guide on MariaDB vs MySQL.

How to Run a MariaDB Docker Appliance?

Many of you skipped right to this part, and we don’t blame you. After all, learning to run MariaDB on Docker is the point of this blog, isn’t it?

To install a MariaDB Docker appliance, follow these steps (if you already have Docker up and running, skip to step #3):

Step 1: Install Docker using curl:

Copy
        
1 curl -sSL https://get.docker.com/ | sh

Step 2: Make sure Docker is running by either starting it yourself or checking its status.

Step 3: Download MariaDB Docker into an image file and create a container. To choose from the available image files, search for MariaDB through Docker with this query:

Copy
        
1 docker search mariadb

Step 4: Choose an official MariaDB image, then create a container with this query:

Copy
        
1 docker pull mariadb:version

To install the default version of MariaDB on Docker (MariaDB 10.4), you would use this query:

Copy
        
1 docker pull mariadb:10.4

Adjust the MariaDB version as necessary.

Awesome! After you run the query above, MariaDB 10.4 will be installed as a MariaDB Docker appliance. Verify by listing all the images in Docker:

Copy
        
1 docker images

Great! You’ve now installed MariaDB in Docker.

Now, create a container by running a command found in the image documentation. For MariaDB 10.4, the command looks like this:

Copy
        
1 docker run --name mariadocker -e MYSQL_ROOT_PASSWORD=chooseasecurepwplease -p 3306:3306 -d docker.io/library/mariadb:10.4

Replace the name and the password with the name of your Docker MariaDB container and the password with the MySQL root password.

Now we have a container called mariadocker. To start, stop, and restart the MariaDB Docker container, use these commands:

  1. docker start mariadocker
  2. docker stop mariadocker
  3. docker restart mariadocker

Now you’re ready to work with MariaDB through Docker!

If you’re after a reference from the Docker team, refer to this guide.

How to Work With a MariaDB Docker Appliance?

Answers to the following MariaDB Docker questions will walk you through everything you need to know to reliably work with any MariaDB Docker appliance:

QuestionAnswer
How to start, stop, or restart my MariaDB Docker appliance?Make use of the commands above: docker start|stop|restart [name] where name is the name of your Docker MariaDB appliance.
Can I specify a time after which to stop my MariaDB Docker appliance?Yes. Make use of the time command (time is defined in seconds): docker stop --time=30 [name]
How to destroy a MariaDB Docker container?Make use of this command: docker rm [-v] [name] The -v destroys the volume of MySQL (the data directory, etc.) as well.
Once I start my MariaDB Docker container, can I set some automatic policies, like cronjobs?Yes, that’s possible. Use the --restart option to set an automatic restart policy. Available values include no, on-failure, unless-stopped, and always. Always restarts containers that were explicitly stopped, the rest of the options are self-explanatory.
How can I pause or unpause a container?docker pause|unpause [name]
Can I access the log files of my MariaDB Docker appliance? How?Yes. All you need to do is issue a logs request followed by the name of your MariaDB Docker appliance: docker logs [name]

The commands above will help you work with your MariaDB Docker appliances, but if you still find yourself searching for a reliable partner in the database space, you should try DbVisualizer.

DbVisualizer is a top-rated SQL client used by well-known names in the industry including Netflix, NASA, Volkswagen, and others, and it offers support for multiple database management systems, too.

We do offer a free 21-day trial, and after that, you will still have access to the functionality in the free version of the tool. Do let us know what you think, explore our blog for other interesting topics on MariaDB Docker containers and other database management systems, and until next time.

FAQ

How to run MariaDB on Docker?

To successfully run a MariaDB Docker installation, first download Docker, then install an official MariaDB image, and create a container. Follow the steps outlined in this blog!

Should I choose MySQL or MariaDB?

Both options are just as good. MariaDB is essentially the same as MySQL, just with a GPL license, and MariaDB supports more data types and storage engines.

Why should I use DbVisualizer?

DbVisualizer is the database client with the biggest user satisfaction in the world. Our SQL client is used by NASA, Google, Spotify, Twitter, and many others, and we do offer a free trial, too. Why not try it out today?

Dbvis download link img
About the author
LukasVileikisPhoto
Lukas Vileikis
Lukas Vileikis is an ethical hacker and a frequent conference speaker. He runs one of the biggest & fastest data breach search engines in the world - BreachDirectory.com, frequently speaks at conferences and blogs in multiple places including his blog over at lukasvileikis.com.
The Table Icon
Sign up to receive The Table's roundup
More from the table
Title Author Tags Length Published
title

A Guide To the SQL DECLARE Statement

author Antonello Zanini tags MySQL ORACLE POSTGRESQL SQL SERVER 7 min 2024-12-12
title

SQL Upsert: Inserting a Record If It Does Not Exist

author Antonello Zanini tags MySQL ORACLE POSTGRESQL SQL SQL SERVER 8 min 2024-12-10
title

A Complete Guide to the MySQL COUNT Function

author Antonello Zanini tags MySQL 9 min 2024-12-09
title

MySQL Nullable Columns: Everything You Need to Know

author Antonello Zanini tags MySQL 6 min 2024-12-03
title

A Complete Guide to the MySQL GROUP_CONCAT Function

author Antonello Zanini tags Data aggregation MySQL 8 min 2024-12-02
title

How and Why to Add an Index in SQL

author Lukas Vileikis tags MySQL POSTGRESQL Search SQL SQL SERVER 8 min 2024-11-28
title

MySQL 9.0 and the New EXPLAIN Features

author Lukas Vileikis tags MySQL SQL 9 min 2024-11-27
title

Massive SQL DELETE Operations and Database Purging Explained

author Lukas Vileikis tags DELETE SQL 4 min 2024-11-26
title

MySQL CAST: A Guide to the Data Conversion Function

author Antonello Zanini tags MySQL 3 min 2024-11-25
title

Postgres Create Array of Numbers: Complete Guide

author Lukas Vileikis tags POSTGRESQL SQL 7 min 2024-11-21

The content provided on dbvis.com/thetable, including but not limited to code and examples, is intended for educational and informational purposes only. We do not make any warranties or representations of any kind. Read more here.

Cookie policy

We use cookies to ensure that we give you the best experience on our website. However you can change your cookie settings at any time in your browser settings. Please find our cookie policy here ↗