Skip to content

Instantly share code, notes, and snippets.

@tristanlins
Last active October 6, 2015 08:51
Show Gist options
  • Save tristanlins/c3c233e66fed180d2f1c to your computer and use it in GitHub Desktop.
Save tristanlins/c3c233e66fed180d2f1c to your computer and use it in GitHub Desktop.
Using docker mariadb as local database
[client]
user=root
password=53CUr3-p422W0RD
host=127.0.0.1
port=3306
# @file /etc/systemd/system/docker-mariadb.service
# @see https://docs.docker.com/articles/host_integration/
[Unit]
Description=MariaDB container
Requires=docker.service
After=docker.service
[Service]
Restart=always
ExecStart=/usr/bin/docker start -a mariadb
ExecStop=/usr/bin/docker stop -t 60 mariadb
[Install]
WantedBy=local.target
# start container
sudo systemctl start docker-mariadb
# stop container
sudo systemctl stop docker-mariadb
# attach shell to container
docker exec -it mariadb bash
# see the logs
docker logs mariadb
# for more see
# https://hub.docker.com/_/mariadb/
# https://docs.docker.com/articles/host_integration/
# create config and data directory
mkdir -p $HOME/docker/mariadb/{config,data}
# initially create the docker container
docker run --restart=on-failure:5 \
--volume=$HOME/docker/mariadb/config:/etc/mysql/conf.d \
--volume=$HOME/docker/mariadb/data:/var/lib/mysql \
--publish=3306:3306 \
--env=MYSQL_ROOT_PASSWORD=53CUr3-p422W0RD \
--hostname=mariadb \
--name=mariadb \
--detach=true \
mariadb:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment