I'm running the next commands:
$ docker-machine ls
NAME ACTIVE DRIVER STATE URL SWARM DOCKER ERRORS
default * virtualbox Running tcp://192.168.99.100:2376 v17.06.2-ce
$ docker-machine ip default
192.168.99.100
And I have some docker containers.
Once of the is running django
, other one postgres
and a third one elastic search.
When I'm running my django
container with:
# python manage.py runserver 0:8000
And it is working when I use the site:
localhost:8000/
But, is not available when I use: 192.168.99.100:8000
There, I have the browser message:
This site can’t be reached
192.168.99.100 refused to connect. Try: Checking the connection
The same happens for the postgres
and elasticseach
container.
Why my docker container is not applying the default docker-machine ip
?
It sounds like you have not told Docker to talk to your VM, and that your containers are running on your host machine.
To resolve:
Bring down your containers
Run $ eval "$(docker-machine env default)"
which sets the following environment variables:
export DOCKER_TLS_VERIFY="1"
export DOCKER_HOST="tcp://x.x.x.x:2376"
export DOCKER_CERT_PATH="/Users/<yourusername>/.docker/machine/machines/default"
export DOCKER_MACHINE_NAME="default"
This tells Docker how to talk to your VM.
Spin containers back up