{"id":6587,"date":"2020-08-03T22:37:02","date_gmt":"2020-08-03T19:37:02","guid":{"rendered":"https:\/\/kifarunix.com\/?p=6587"},"modified":"2024-03-14T22:46:46","modified_gmt":"2024-03-14T19:46:46","slug":"install-and-run-mariadb-as-a-docker-container","status":"publish","type":"post","link":"https:\/\/kifarunix.com\/install-and-run-mariadb-as-a-docker-container\/","title":{"rendered":"Install and Run MariaDB as a Docker Container"},"content":{"rendered":"\n

Welcome to our basic tutorial on how to install and run MariaDB as a Docker container. According to Docker website<\/a>, “Docker is an open platform for developing, shipping, and running applications<\/em>“. A container<\/a> on the hand “is a standard unit of software that packages up code and all its dependencies so the application runs quickly and reliably from one computing environment to another. A Docker container image is a lightweight, standalone, executable package of software that includes everything needed to run an application: code, runtime, system tools, system libraries and settings<\/em>“.<\/p>\n\n\n\n

Installing MariaDB as a Docker Container<\/h2>\n\n\n\n

Install Docker Engine<\/h3>\n\n\n\n

Before you can proceed, install Docker Engine on your system. Follow the links below to install Docker Engine on CentOS 8\/Ubuntu 20.04 systems;<\/p>\n\n\n\n

Install and Use Docker CE on CentOS 8<\/a><\/p>\n\n\n\n

Install Docker CE on Ubuntu 20.04<\/a><\/p>\n\n\n\n

Download MariaDB Docker Image<\/a><\/h3>\n\n\n\n

Every docker container is based off a specific image. Docker image contains everything that is necessary to run a container and is therefore a series of instructions that defines how an application is run.<\/p>\n\n\n\n

You can build your own Docker image or simply utilize the images that the community have created. You can find the images at the Docker Hub<\/a>.<\/p>\n\n\n\n

In this tutorial, we will be utilizing the community available Docker images.<\/p>\n\n\n\n

Search for MariaDB Docker Image<\/a><\/h4>\n\n\n\n

First off, you need to identify the name of the specific MariaDB Docker Image. To search for the image on the docker hub, simply run the command below;<\/p>\n\n\n\n

docker search mariadb<\/code><\/pre>\n\n\n\n

You will get a ton of MariaDB images that have been created;<\/p>\n\n\n\n

NAME                                   DESCRIPTION                                     STARS               OFFICIAL            AUTOMATED\nmariadb                                MariaDB is a community-developed fork of MyS\u2026   3572                [OK]<\/strong>                \nlinuxserver\/mariadb                    A Mariadb container, brought to you by Linux\u2026   151                                     \nbitnami\/mariadb                        Bitnami MariaDB Docker Image                    120                                     [OK]\ntoughiq\/mariadb-cluster                Dockerized Automated MariaDB Galera Cluster \u2026   41                                      [OK]\n...<\/code><\/pre>\n\n\n\n

Usually, an image with no prefix is considered official docker hub image, stable and being maintained. It also contains [OK]<\/strong> on the Official<\/strong> column. Therefore, we will pull the first image from the list above.<\/p>\n\n\n\n

Download MariaDB Docker Image from Docker Hub<\/a><\/h4>\n\n\n\n

To download the Docker Image, you use the docker pull <name-of-the-image><\/em><\/code> command. In this case, our image name is mariadb<\/strong><\/code>.<\/p>\n\n\n\n

docker pull mariadb<\/code><\/pre>\n\n\n\n

The command downloads the image to your system, if doesn’t already exist.<\/p>\n\n\n\n

By default, when you pull a docker image, the latest version of it is downloaded. If you need to download other versions of MariaDB Docker Images, for example, MariaDB 10.3 Docker Image, simply use the command;<\/p>\n\n\n\n

docker pull mariadb:10.3<\/code><\/pre>\n\n\n\n

You can see a wide range of tags you can use on Docker Hub MariaDB<\/a> page.<\/p>\n\n\n\n

List Downloaded Docker Images<\/h4>\n\n\n\n

You can list locally available images using the docker images<\/strong><\/code> command.<\/p>\n\n\n\n

docker images<\/code><\/pre>\n\n\n\n
REPOSITORY          TAG                 IMAGE ID            CREATED             SIZE\nmariadb             latest              8075b7694a2d        8 days ago          407MB<\/code><\/pre>\n\n\n\n

We have the latest MariaDB Docker Image downloaded.<\/p>\n\n\n\n

Running MariaDB Docker Container<\/a><\/h3>\n\n\n\n

Once you have the Docker image in place, you can then create and run a docker container based on the image. docker run <options> <image-name><\/em><\/strong><\/code> is the Docker command for running Docker containers.<\/p>\n\n\n\n

When running a MariaDB container, you need to specify one of following environment variables:<\/p>\n\n\n\n