Search code examples
dockerdocker-networkdocker-for-windowslinux-containers

How do i make my docker container accessible to machines other than my host machines


I am running docker on my windows 10 machine , i have docker for windows installed and when i run selenium hub image with exposes ports it works fine , I can view the selenium hub console with localhost:4444 (4444 is the exposed port) . Now i want other machines connected to the same network to be able to connect to my selenium hub container .

How can i achieve this .

I have exposed ports using -p 4444:4444 , but this looks good for working between the host machine and the docker container.

hub: image: selenium/hub:latest ports: - "4444:4444"


Solution

  • You have already done everything you need, as mentioned @mostafa in comments. When you expose ports, you actually map internal docker network ports onto host's ones, thus making your services available from host.

    The only thing you have to care about - is host interface, to which the services are being bound. By default, when you write -p 123:123 docker maps to 0.0.0.0 that means services become available on all networks, where host is connected.

    You can explicitly specify this in form -p <interface>:123:456 to make this port only visible in specified network.