英文:
How can I access an NGINX web server running inside a Docker container on a virtual machine managed by Vagrant, from my Windows host machine?
问题
我已经设置了Vagrantfile来使用具有IP地址192.168.1.10的公共网络:
# -*- mode: ruby -*-
# vi: set ft=ruby :
Vagrant.configure("2") do |config|
config.vm.box = "laravel/homestead"
config.vm.network "public_network", ip: "192.168.1.10"
config.vm.provider "virtualbox" do |vb|
vb.name = "Agent1"
end
config.vm.provision "docker" do |vb|
end
config.vm.hostname = "Agent1"
end
我已使用命令 docker run -it -p 88:80 nginx
启动了Docker容器,将容器内的端口80映射到主机上的端口88。然而,当我尝试在我的Web浏览器中使用URLs,如192.168.1.10:88、localhost:88或127.0.0.1:88来访问Web服务器时,它无法正常工作。
可能导致此问题的原因是什么,我应该使用哪个URL来从我的Windows主机机器访问NGINX Web服务器?
英文:
I have set up the Vagrantfile to use a public network with IP address 192.168.1.10 :
# -*- mode: ruby -*-
# vi: set ft=ruby :
Vagrant.configure("2") do |config|
config.vm.box = "laravel/homestead"
config.vm.network "public_network", ip: "192.168.1.10"
config.vm.provider "virtualbox" do |vb|
vb.name = "Agent1"
end
config.vm.provision "docker" do |vb|
end
config.vm.hostname = "Agent1"
end
I have launched the Docker container with the command docker run -it -p 88:80 nginx
to map port 80 inside the container to port 88 on the host machine. However, when I try to access the web server using URLs like 192.168.1.10:88, localhost:88, or 127.0.0.1:88 in my web browser, it doesn't work.
What could be causing this issue, and what URL should I use to access the NGINX web server from my Windows host machine?
答案1
得分: 0
你尚未将虚拟机的端口88转发到您的主机。
首先,请检查您是否能够通过SSH连接到该虚拟机并运行 curl localhost:88
。
英文:
You've not forwarded port 88 on the VM to your host.
First check you can SSH into that machine and curl localhost:88
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论