I am having some issues connecting to the mysql docker container that I have launched with docker-compose. This is a long post (sorry!).
Here is my docker-compose.ym
Environment variables in docker-compose.yml file should not have quotes when using array definition:
db:
image: mysql:5.7
ports:
- "3306:3306"
environment:
- MYSQL_ROOT_PASSWORD=secret
- MYSQL_USER=django
- MYSQL_PASSWORD=secret
- MYSQL_DATABASE=myAppDB
If you use them in your docker-compose.yml file:
db:
image: mysql:5.7
ports:
- "3306:3306"
environment:
- MYSQL_ROOT_PASSWORD="secret"
- MYSQL_USER="django"
- MYSQL_PASSWORD="secret"
- MYSQL_DATABASE="myAppDB"
and run:
$ docker-compose up -d
and enter running container:
$ docker-compose exec db /bin/bash
you will see the output:
root@979813643b0c:/# echo $MYSQL_ROOT_PASSWORD
"secret"