Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Networking with Docker on Windows

I used this official guide to set up Docker on a Windows 7 machine:

https://docs.docker.com/windows/started/

I successfully pulled an image from the docker hub and I can run my own docker image.

No I am stuck trying to run and access a webserver with docker on Windows. Apparently, behind boot2docker I can't reach my docker container the way I was used to.

Once I added -p 3007:80 to the docker run command, the port forwarding showed up in the container list (docker ps) as 0.0.0.0:3007 -> 80. And with -p 127.0.0.1:3007:80 I get a more meaningful ip address. I cannot, however, reach the container with a browser on the Windows host.

Moreover, docker inspect does not reveal an ip address for the running container (which also seems wrong).

I also tried --net=host to no avail.

like image 546
ruben.moor Avatar asked Sep 28 '15 15:09

ruben.moor


People also ask

Can I work with Docker on Windows?

You can run both Linux and Windows programs and executables in Docker containers. The Docker platform runs natively on Linux (on x86-64, ARM and many other CPU architectures) and on Windows (x86-64). Docker Inc. builds products that let you build and run containers on Linux, Windows and macOS.

How do I connect to a Docker container over a network?

Connect a container to a network when it starts You can also use the docker run --network=<network-name> option to start a container and immediately connect it to a network.

Can Docker access local network?

docker run --network="host" Alternatively you can run a docker container with network settings set to host . Such a container will share the network stack with the docker host and from the container point of view, localhost (or 127.0. 0.1 ) will refer to the docker host.

How does Docker do networking?

Docker includes support for networking containers through the use of network drivers. By default, Docker provides two network drivers for you, the bridge and the overlay drivers. You can also write a network driver plugin so that you can create your own drivers but that is an advanced task.


1 Answers

Things changed a little with the introduction of Docker Toolbox. Now you do not directly interact with boot2docker, but instead use docker-machine. Although boot2docker still exists as VM there is no CLI-Tool any longer. It was replaced by Docker Machine.

Thus you should be able to get hold of the VM's IP address by typing: docker-machine ip <machine-name>. If you do have the default installation your machine name will be default.

With docker-machine active you can have a look which VM is currently active. With that name you can also use docker-machine inspect <machine-name>.

You can find more about Docker Machine in the official docs.

like image 192
Jan Suchotzki Avatar answered Sep 21 '22 22:09

Jan Suchotzki