Using this tutorial https://semaphoreci.com/community/tutorials/dockerizing-a-python-django-web-application, I'm dockering my Django application in a VirtualBox using docker-machine. Everything has gone splendidly until I go to my browser and my application says that it's having issues with MySQL.
Then i found this documentation for dockerizing an instance of mysql https://github.com/mysql/mysql-docker which I followed, creating the image in the same development VirtualBox that I created. The error I was originally getting was
Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' My Django DATABASES looked like this
DATABASES = { 'default': { 'ENGINE': 'django.db.backends.mysql', 'NAME': 'db_name', 'USER': 'root', 'HOST': 'localhost', 'PORT': '' } } I then changed the host to 127.0.0.1 and even tried specifying the port as 3306 and I got a new error which was
(2003, "Can't connect to MySQL server on '127.0.0.1' (111)") I also went in to MySQL workbench and changed the connection of my Local instance to be 127.0.0.1:3306 and that hasn't helped.
The commands that I'm running are
eval "$(docker-image env development)" ---> supposedly does THESE things:
export DOCKER_TLS_VERIFY="1" export DOCKER_HOST="tcp://123.456.78.910:1112" export DOCKER_CERT_PATH="/Users/me/.docker/machine/machines/development" export DOCKER_MACHINE_NAME="development" Then, now that i'm in my virtualbox, I run:
docker run -it -p 8000:8000 <docker image name> ---> forwards exposed port 8000 to port 8000 on my local machine
docker run -it -p 3306:3306 mysql/mysql-sever ---> forwards exposed port 3306 to port 3306 on my local machine