mirror of
https://github.com/hashicorp/vagrant.git
synced 2026-02-03 20:39:27 -05:00
40 lines
1.1 KiB
Text
40 lines
1.1 KiB
Text
---
|
|
layout: docs
|
|
page_title: vagrant port - Command-Line Interface
|
|
description: |-
|
|
The "vagrant port" command is used to display the full list of guest ports
|
|
mapped to the host machine ports.
|
|
---
|
|
|
|
# Port
|
|
|
|
**Command: `vagrant port [name|id]`**
|
|
|
|
The port command displays the full list of guest ports mapped to the host
|
|
machine ports:
|
|
|
|
```shell-session
|
|
$ vagrant port
|
|
22 (guest) => 2222 (host)
|
|
80 (guest) => 8080 (host)
|
|
```
|
|
|
|
In a multi-machine Vagrantfile, the name of the machine must be specified:
|
|
|
|
```shell-session
|
|
$ vagrant port my-machine
|
|
```
|
|
|
|
## Options
|
|
|
|
- `--guest PORT` - This displays just the host port that corresponds to the
|
|
given guest port. If the guest is not forwarding that port, an error is
|
|
returned. This is useful for quick scripting, for example:
|
|
|
|
```shell-session
|
|
$ ssh -p $(vagrant port --guest 22)
|
|
```
|
|
|
|
- `--machine-readable` - This tells Vagrant to display machine-readable output
|
|
instead of the human-friendly output. More information is available in the
|
|
[machine-readable output](/vagrant/docs/cli/machine-readable) documentation.
|