Docker Community Forums

Share and learn in the Docker community.

Accessing local network hosts from container

Hello,
I need your help, to connect my container to my VM.
This is my config.
I use the webdevops/php-apache-dev image
I am on windows 10
I have a server working on a VM in my local network, my PC and my VM are on the same subnet.
I would like to access to this VM from my container.

I can ping the VM from my PC
I can ping the internet from my PC
I can ping my PC from the VM
I can ping the internet from the VM

I can’t ping my PC from the container
I can’t ping the VM from the container
I can ping the internet from the container.

What is the configuration to use in the docker-compose file to be able to ping the VM from the container ?
Thank you.

All your hosts should be accessible by their IP address. If you try with a standard image

docker container run --rm alpine ping -c 5 $SOME_IP_ADDRESS

does this work?
Don’t know what I should say about the mentioned webdevops image. It has no documentation and their website has an invalid SSL certificate.

Sorry for late answer…
I tried your tip, but doesn’t work :

$ docker container run --rm alpine ping -c 5 172.17.171.15
PING 172.17.171.15 (172.17.171.15): 56 data bytes
— 172.17.171.15 ping statistics —
5 packets transmitted, 0 packets received, 100% packet loss

I would like to know if there is a special config to do in the dockerfile or docker-compose to allow container to connect a host on the lan.
Thank you?