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
Once you have cloned the repository, create a new .env
file and set your safe passwords there.
cp env.example .env
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
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
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
To create a new user with it's related database, there is a create.sh
script:
./dc exec mariadb create.sh cowork
To drop an existing user with it's related database, there is a drop.sh
script:
./dc exec mariadb drop.sh cowork
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