Skip to content

Instantly share code, notes, and snippets.

@oneamtu oneamtu/mysql_docker.sh
Last active May 24, 2019

Embed
What would you like to do?
set up docker persistent database instance for development
export ROOT_MYSQL_PASSWORD="blah" #CHANGEME
sudo docker pull percona:5.6
# To run the daemon
sudo docker run --restart unless-stopped --name percona-5.6 -p 127.0.0.1:3306:3306 -v /data/mysql-5.6:/var/lib/mysql -e MYSQL_ROOT_PASSWORD=$ROOT_MYSQL_PASSWORD -d percona:5.6
# To check/run a console
sudo docker run -it --link percona-5.6:mysql --rm percona sh -c 'exec mysql -h"$MYSQL_PORT_3306_TCP_ADDR" -P"$MYSQL_PORT_3306_TCP_PORT" -u$(echo $ROOT_MYSQL_USER) -p$(echo $ROOT_MYSQL_PASSWORD)'
# To start/stop
docker start percona-5.6
docker stop percona-5.6
# set ROOT_PGSQL_PASSWORD
docker pull postgres
docker run --name postgres -p 127.0.0.1:5432:5432 -v /pgdata:/var/lib/postgresql/data/pgdata -e POSTGRES_PASSWORD=$ROOT_PGSQL_PASSWORD -e PGDATA=/var/lib/postgresql/data/pgdata -d postgres
# To check
docker run -it --link postgres:postgres --rm postgres sh -c 'exec psql -h "$POSTGRES_PORT_5432_TCP_ADDR" -p "$POSTGRES_PORT_5432_TCP_PORT" -U postgres'
docker start postgres
docker stop postgres
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.