← 返回命令列表

Linux command

vagrant-port 命令

文本

复制后可按需替换文件名、目录或参数。

常用示例

Show port mappings

vagrant port

Show for specific VM

vagrant port [name]

Show host port for a specific guest port

vagrant port --guest [80]

SSH using the forwarded port

ssh -p $(vagrant port --guest 22) vagrant@localhost

说明

vagrant port displays guest to host port mappings. Shows forwarded ports configured for the VM. Useful for finding the host port to access services in the guest.

参数

--guest _port_
Show only the host port that maps to the specified guest port. Returns an error if the port is not forwarded. Useful for scripting.
--machine-readable
Machine-readable output format for automation.

FAQ

What is the vagrant-port command used for?

vagrant port displays guest to host port mappings. Shows forwarded ports configured for the VM. Useful for finding the host port to access services in the guest.

How do I run a basic vagrant-port example?

Run `vagrant port` in a terminal, then adjust file names, paths, flags, or remote targets for your system.

What does --guest _port_ do in vagrant-port?

Show only the host port that maps to the specified guest port. Returns an error if the port is not forwarded. Useful for scripting.