Skip to content

Latest commit

 

History

History
103 lines (67 loc) · 2.11 KB

README.md

File metadata and controls

103 lines (67 loc) · 2.11 KB

MariaDB for Docker

Install

To start using this container, start by cloning the repository:

git clone https://github.com/hawara-es/mariadb-for-docker.git
cd mariadb-for-docker

Configure

Once you have cloned the repository, create a new .env file and set your safe passwords there.

cp env.example .env

Docker Container

To start the container with minimum settings, just run:

docker compose up -d

Which is equivalent to loading the default docker-compose.yml:

docker compose -f docker-compose.yml up -d

To start the container with the 3306 port binded to the host, use the docker-compose.port.yml file:

docker compose -f docker-compose.yml -f docker-compose.port.yml up -d

The dc Helper

To standardize calling Docker from the project root, the dc filename has been added to this project's .gitignore.

You are encouraged to create it either if you will be only using the standard file:

#!/bin/bash
docker compose -f docker-compose.yml "$@"

... or if you will also be using the open port file:

#!/bin/bash
docker compose -f docker-compose.yml -f docker-compose.port.yml "$@"

Thanks to this, and after giving executing permissions to the new file, you will be able to use this short hand:

# chmod +x dc
./dc up -d

Test the Container Health

The container makes use of MariaDB's standard healthcheck.sh, so by running a ps you should see a report about the health of your container:

./dc ps

Maintenance Scripts

Create a Database

To create a new user with it's related database, there is a create.sh script:

./dc exec mariadb create.sh cowork

Drop a Database

To drop an existing user with it's related database, there is a drop.sh script:

./dc exec mariadb drop.sh cowork

Backup the Databases

To run backups for all the databases, you can use the bundled dump.sh script:

./dc exec mariadb dump.sh

Alternatively, you can specify the database to dump:

./dc exec mariadb dump.sh cowork > backups/cowork`date +%F\T%T\Z`.sql