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:
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
:
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:
1
docker search mariadb
Step 4: Choose an official MariaDB image, then create a container with this query:
1
docker pull mariadb:version
To install the default version of MariaDB on Docker (MariaDB 10.4), you would use this query:
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:
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:
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:
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:
Question | Answer |
---|---|
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?