Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Populate mysql docker container from sql file
# Create a mysql container
docker run --name myDb -e MYSQL_DATABASE=db-name -e MYSQL_ROOT_PASSWORD=topsecret -p 3306:3306 -d mysql
# Populate it
docker run --rm -it --link myDb:mysql -v ${PWD}:/dump mysql sh -c 'exec mysql -h"$MYSQL_PORT_3306_TCP_ADDR" -P"$MYSQL_PORT_3306_TCP_PORT" -uroot -p"$MYSQL_ENV_MYSQL_ROOT_PASSWORD" --database="$MYSQL_ENV_MYSQL_DATABASE" < /dump/my-dump.sql'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment