In this tutorial, we'll learn how to install MariaDB using Docker-Compose. By using Docker-Compose, we can configure an image the way we want and can turn the image on and of as needed.
Create a new directory for your MariaDB project.
Inside of this directory, create a
data directory and a
Project_Folder_For_Database |---data |___docker-compose.yml
Inside of the
docker-compose.yml file paste this:
version: '3.7' services: database: container_name: docker-local-mariadb image: mariadb volumes: - "./data:/var/lib/mysql" restart: always ports: - 3306:3306 environment: MYSQL_ROOT_PASSWORD: 0123456789
Start the Container
To start the container run this
docker-compose up -d
Stop the Container
To stop the container run this
Whenever MariaDB modifies any data it will be persist locally inside of your
Run Commands Inside of the Container
To run Bash commands run this
docker-compose exec database bash
This will give you shell access to the container.
In this short tutorial, we'll learn how to spin up MariaDB with Docker-Compose and how to get
shell access to the