Hi there,
I started to learn Docker a few days ago, and I’m encountering an issue which looks like a networking issue.
I have atm a dev environment provided by Vagrant and orchestrated by Puppet, and I what I want is to switch from Puppet code to Docker containers. All the containers must be running within the host computer, not in the VM.
What I’m trying to do, to begin with, is to migrate the redis-server in a container.
To make some tests before integrating a more complex Dockerfile is a simple docker run -d --name redis -p 6379:6379 redis
It creates the container, running and accessible from the host with a redis-cli ping
. The redis default image contains EXPOSE 6379.
The network used is, by default, bridge mode docker0 172.17.0.0/16.
The issue is : I can’t access my redis from my VM. redis-cli -h 172.17.0.2
is returning “No route to host”, and redis-cli ping
“Cannot connect to 127.0.0.1” or something.
In my Vagrantfile, I got the forwarded ports 6379 enabled, first adapter is NAT and the second is host-only (network 192.168.33.0/24, I have my dev box and my elasticsearchbox on it)
I looked into iptables but Docker seems to “allow anywhere” by default. I tried to add ip routes too, without any success. Bridge mode on VBox instead of host-only doesn’t seems to work, but I may be doing something wrong.
I’m able to ping 172.17.0.1 from my VM (docker0 interface from the host computer), but I can’t reach 172.17.0.2 (container’s internal IP)
I also have a .env file in my laravel folder, specifying REDIS_HOST and REDIS_PORT, doesn’t work too with 172.17.0.2:6379.
I made a quick draw of what I think my private network looks like, more or less : https://imgur.com/a/coDdr
I think I’m missing something, it’s maybe obvious for someone ? I could need help there
Thanks for your time