Install MariaDB via the Docker container

#Introduction

In this tutorial, How to Install MariaDB via docker. MariaDB is a popular open-source database server.

You need to install Docker on Ubuntu.

Install MariaDB via Docker

Download MariaDB Docker Image.

docker search mariadb
docker pull mariadb
Download MariaDB Docker Image.

Get a list of installed images on Docker.

docker images
Get a list of installed images

Creating a MariaDB Container

We will create a MariaDB Container such as the flags below:

  • –name my-mariadb: To set the name of the container. If nothing is specified a random if will be automatically generated.
  • –env MYSQL_ROOT_PASSWORD=password_secret: Setting root password to Mariadb.
  • –detach is to run the container in the background.
docker run --detach --name my-mariadb --env MARIADB_USER=example-user --env MARIADB_PASSWORD=example_user_password_secret --env MARIADB_ROOT_PASSWORD=password_secret mariadb:latest

Get the active docker container

docker ps
Creating a MariaDB docker Container

The container is running, How to access it?

docker exec -it my-mariadb mysql -uexample-user -p
How to access mariadb docker container

Starting and Stopping MariaDB Container

restart MariaDB container

docker restart my-mariadb

stop MariaDB container

docker stop my-mariadb

start MariaDB container

docker start my-mariadb

In case we want to destroy a container,

docker rm -v my-mariadb
Install MariaDB via Docker

Conclusion

You Install MariaDB via Docker container. I hope this will be helpful. Thank you for reading the DevopsRoles page!

About HuuPV

My name is Huu. I love technology and especially Devops Skill such as Docker, vagrant, git so forth. I likes open-sources. so I created DevopsRoles.com site to share the knowledge that I have learned. My Job: IT system administrator. Hobbies: summoners war game, gossip.
View all posts by HuuPV →

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.