关于vagrant端口映射的问题
来源:4-4 Docker bridge0详解
sliverg
2019-01-14
老师你好:
我在vagrantfile中添加了
config.vm.network "forwarded_port", guest: 5000, host: 5000
然后使用vagrant reload
命令重启,输出
➜ vagrant reload
==> web: Attempting graceful shutdown of VM...
==> web: Checking if box 'centos/7' version '1811.02' is up to date...
==> web: Clearing any previously set forwarded ports...
==> web: Fixed port collision for 22 => 2222. Now on port 2201.
==> web: Clearing any previously set network interfaces...
==> web: Preparing network interfaces based on configuration...
web: Adapter 1: nat
web: Adapter 2: hostonly
==> web: Forwarding ports...
web: 5000 (guest) => 5000 (host) (adapter 1)
web: 22 (guest) => 2201 (host) (adapter 1)
==> web: Running 'pre-boot' VM customizations...
==> web: Booting VM...
==> web: Waiting for machine to boot. This may take a few minutes...
web: SSH address: 127.0.0.1:2201
web: SSH username: vagrant
web: SSH auth method: private key
==> web: Machine booted and ready!
[web] GuestAdditions seems to be installed (6.0.0) correctly, but not running.
Redirecting to /bin/systemctl start vboxadd.service
Redirecting to /bin/systemctl start vboxadd-service.service
==> web: Checking for guest additions in VM...
==> web: Setting hostname...
==> web: Configuring and enabling network interfaces...
==> web: Rsyncing folder: /Users/s/Vagrant/centos7/ => /vagrant
==> web: Machine already provisioned. Run `vagrant provision` or use the `--provision`
==> web: flag to force provisioning. Provisioners marked to run always will still run.
~/Vagrant/centos7 took 39s
看输出日志没有任何的错误,但是我在宿主机上使用telnet
去访问5000
端口一直失败。
~/Vagrant/centos7 took 18s
➜ telnet 192.168.100.100 5000
Trying 192.168.100.100...
telnet: connect to address 192.168.100.100: Connection refused
telnet: Unable to connect to remote host
~/Vagrant/centos7 took 31s
请问这个问题怎么解决啊??????
写回答
1回答
-
麦兜搞IT
2019-01-15
您好。
第一,确保主机上能ping通192.168.100.100
第二,您的vagrant上有什么服务开启了5000端口么,首先要确保你在vagrant主机内部能通过telnet 127.0.0.1 5000 连接上。
022019-01-16
相似问题
映射本地5000端口
回答 1
端口映射失败
回答 1