7.1 端口映射實現訪問容器
docker run -P 會隨機分配一個端口暴露給主機, -p 可以指定一個端口
-p, --publish list Publish a container's port(s) to the host (default [])
-P, --publish-all Publish all exposed ports to random ports
docker port 查看端口映射
7.2 容器互聯實現容器間通信
--link name:alias 讓 當前容器hosts中添加 另一容器的地址 。反過來不行,因爲先後啓動。
能直接ping通ng
是因爲 在hosts中設置了 ng的地址
不能從ng到ng2