Networking with Docker on Windows

I used this official guide to configure Docker on a computer running Windows 7:

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

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

No. I'm stuck trying to start a web server and connect to docker in Windows. Apparently, for boot2dockerI can't get to the docker container the way I'm used to.

As soon as I added -p 3007:80to the command docker run, port forwarding appeared in the list of containers ( docker ps) as 0.0.0.0:3007 -> 80. And with -p 127.0.0.1:3007:80I get a more meaningful IP address. However, I cannot reach the container using a browser on a Windows host.

In addition, it docker inspectdoes not show the IP address for the running container (which also seems wrong).

I also tried to --net=hostno avail.

+3
source share
2 answers

Slightly changed with the introduction of the Docker Toolbox. Now you are not directly interacting with boot2docker, but using instead docker-machine. Although boot2dockerit still exists as a VM, the CLI-Tool no longer exists. It has been replaced by the Docker Machine.

Thus, you should be able to get the IP-address of the virtual machine by typing: docker-machine ip <machine-name>. If you have the default setting installed, your machine name will be default.

docker-machine active , . docker-machine inspect <machine-name>.

Docker Machine .

+6

, : Docker Windows , Boot2Docker Docker Toolbox . Windows 10 ( Windows Server 2016).

Docker Windows , - :

  • (, docker run -d -p hostport:containerport imagename)
  • Shell (, Windows: docker exec -it containerName powershell docker exec -it containerName bash, Linux) , iwr http://localhost:80 -UseBasicParsing HTML HTTP 200
  • 2. ( ), IP- (, docker network inspect dockerNetworkName, , IP-) http://containerIP:containerPort.
  • 3. ( : ), , - http://localhost:containerPort (, , Windows, localhost loopback - Windows 10/Server 2016)
  • ( 1., 2. 3. , 4. ), - - Windows (, Windows , !)
+2

Source: https://habr.com/ru/post/1610471/


All Articles