Clone the mysql dockerfile repo
git clone https://github.com/docker-library/mysql.git
cd mysql/5.7
Create an env
file
development.env
MYSQL_ROOT_PASSWORD=mypassword
MYSQL_USER=SvcUser
MYSQL_PASSWORD=myservicepassword
MYSQL_DATABASE=my_service
Build and Run the image
docker build .
docker run --name=mysql1 --env-file development.env -p 3306:3306 <image-id>
docker exec -it mysql1 bash
mysql -u SvcUser -pmyservicepassword
mysql -h 127.0.0.1 -u SvcUser -pmyservicepassword
Note: must use 127.0.0.1
and not localhost
ifconfig # find your local ip address
# test that you can connect to your dev machine's ip address
mysql -h 192.168.1.142 -u SvcUser -pmyservicepassword