先上示例
如上圖,
運作容器 httpd 的時候添加了 -p 參數,
--publish | -p
上圖中,使用的是 hostPort : containerPort 的寫法(當然還有其他的寫法)
表示将兩者進行映射
在上面的例子中,也就是通路容器的主控端(server1)的 8000 端口,會被映射到容器的 80 端口
而 80 端口正是 httpd 的監聽端口
是以,在容器運作的過程中,從實體機上通路 容器主控端 server1 的 8000 端口時,
就得到了 httpd 傳回的内容
進入該容器,能看到被傳回的文本如下:
/usr/local/apache2/index.html
podman ps 的時候,也能看到
Ports 字段,多了 0.0.0.0:8000 -> 80/tcp 的提示,
此外,通過 <code>podman port</code> 也能檢視端口的映射情況
List port mappings for a container