1. 程式人生 > >virtualbox+vagrant學習-2(command cli)-10-vagrant Port命令

virtualbox+vagrant學習-2(command cli)-10-vagrant Port命令

Port

格式:

vagrant port [options] [name|id]

埠命令顯示對映到主機埠的客戶埠的完整列表

userdeMacBook-Pro:~ user$ vagrant port -h
Usage: vagrant port [options] [name|id]

Options:

        --guest PORT                 Output the host port that maps to the given guest port 輸出對映到給定客戶埠的主機埠
        --machine-readable           Display machine-readable output  顯示機器可讀的輸出
    
-h, --help Print this help 列印幫助資訊

例子:

得到的是本機所有機器的埠對映資訊

userdeMacBook-Pro:~ user$ vagrant port
The forwarded ports for the machine are listed below. Please note that
these values may differ from values configured in the Vagrantfile if the
provider supports automatic port collision detection and resolution.

    
22 (guest) => 2222 (host)

 

如果只想得到某個機器的,可以指明其名字或id,如:

$ vagrant port my-machine