System environment:
Host system: windows 8
Virtual machine software: Oracle VirtualBox (CentOS7)
docker version : 19.03.7
Problem description
1. Systemctl start docker inside the virtual machine starts docker
2. docker run -d -p 80:80 nginx starts nginx service
3. Virtual machine ip 192.168.56.200, docker service ip 172.17.0.16
4. Host browser localhost:81 cannot access nginx
The solution is as follows:
1. Open virtualbox
2. Select the virtual machine where the docker service is located
3. Click Settings-> Network
4. Select the NAT network card
5. Click Advanced-> Port Forwarding
6. Add rules: tcp protocol, host and subsystem port settings, such as host:80 guest:80
7. Visit localhost:80 with the browser and you can view the nginx interface
##Recommended tutorial:The above is the detailed content of How does the host host access the docker service in the virtual machine?. For more information, please follow other related articles on the PHP Chinese website!