1

I'm trying to create a Docker container that I can connect to from any device on my local network. Specifically, this container: https://hub.docker.com/r/codercom/code-server. I've tried using Docker Desktop and Docker Toolbox but I've only been able to get it working on my host device. How do I configure my network or other settings to allow other devices on my local network to connect to the container?

I've tried following similar stackoverflow questions, docker forums, and youtube videos. I've tried setting of bridged network connections but nothing has worked for me.

These are some of the sites that I've been on and tried to replicate the solution to my similar problem.

 https://forums.docker.com/t/bridge-with-docker-for-windows/30936
 https://stackoverflow.com/questions/39111247/how-to-access-docker-container-from-another-machine-on-local-network
 https://blog.oddbit.com/post/2014-08-11-four-ways-to-connect-a-docker/

Edit1: The command that I run is: docker run -it -p 127.0.0.3:8443:8443 -v "${PWD}:/home/coder/project" codercom/code-server --allow-http --no-auth This part works but when I try to access 127.0.0.3:8443 from a different computer on the same network it doesn't work. I've tried to solutions from the links that I posted above but I get the same result where the address that I put in fails to load.

What I want to do is host code-server from my desktop computer and allow for a device like a laptop to connect to the code-server. I'm currently on a windows 10 pro machine. Can anyone lead me into the right sort of direction?

  • You're probably looking for the `docker run -p` option. If that's not working, editing this question to include a specific `docker run` command and a specific error reaching it from off-host would be helpful. – David Maze Jun 03 '19 at 04:14
  • Thanks for the quick reply! It's not that docker isn't working at all, it just doesn't work from a different computer on the same network. I've tried configuring it so that it allows connections from other devices but I've had no luck so far. I believe it is possible to do so but I'm not even entirely sure. Sorry if my question is confusing. – Blanco Yisom Jun 03 '19 at 04:34
  • Where did you get this ip from (127.0.0.3)? First of all you shoudn't use it at all in the docker run command. When you connect from a different computer you should use the host's IP on your network (the same you would use to say ping that host) – Mihai Jun 03 '19 at 05:45
  • I didn't get 127.0.0.3 from anywhere. It was just a random ip that I knew that I could type into my browser and the VSCode server would popup. I'm not sure how to connect from a different computer in the first place. – Blanco Yisom Jun 03 '19 at 05:50

1 Answers1

1

Solution:

When I installed Docker for Windows, it creates a network called vEthernet (DockerNAT) (Usually with the IP 10.0.75.1)

My local machine had a network called local area connection with the IP 192.168.0.172(With this IP I was trying to access from other PCs).

So far, My local Machine had Two networks Connections so that I went to Control panel > NetWork and Sharing center > Change Adapter Settings I selected the two networks and I right-click selected Add to bridge. That creates a Third network called Ethernet.

At this point, I didn't know what was the Ip of Ethernet network, so I executed ipconfig command that shows me the IP 192.168.0.17(The settings of local area connection and vEthernet (DockerNAT) disappeared and the IP's 10.0.75.1 and 192.168.0.172 stop working).

With this new IP (192.168.0.17) I tried from another machine in the network and finally I could access to the container(192.168.0.17:9090).

Important if you have a firewall enabled then you need to execute the below script in PowerShell

if (!(Get-NetFirewallRule | where {$_.Name -eq “gitlab 9090”})) { New-NetFirewallRule -Name “gitlab 9090” -DisplayName “gitlab 9090” -Protocol tcp -LocalPort 9090 -Action Allow -Enabled True}

Replace the gitlab and port 9090 with your image name and port.

deanavenger
  • 582
  • 1
  • 7
  • 24