请稍等 ...
×

采纳答案成功!

向帮助你的同学说点啥吧!感谢那些助人为乐的人

dockerfile里面的expose 指定的端口作用?

dockerfile里面的expose 指定的端口作用?
只是为了后期方便查看这个image会启动那些端口吗?如果不写是不是后期照样可以启动?

正在回答 回答被采纳积分+3

1回答

麦兜搞IT 2018-09-21 09:31:28

您好,不写也是可以的,您可以把它看成是一种文档功能,让Dockerfile的作者和这个image的使用者知道可以暴露哪些端口。下面是docker的官方文档定义

The EXPOSE instruction does not actually publish the port. It functions as a type of documentation between the person who builds the image and the person who runs the container, about which ports are intended to be published. To actually publish the port when running the container, use the -p flag on docker run to publish and map one or more ports, or the -P flag to publish all exposed ports and map them to high-order ports.

0 回复 有任何疑惑可以回复我~
问题已解决,确定采纳
还有疑问,暂不采纳
微信客服

购课补贴
联系客服咨询优惠详情

帮助反馈 APP下载

慕课网APP
您的移动学习伙伴

公众号

扫描二维码
关注慕课网微信公众号