知识卡片
暴露端口不等于发布到主机
EXPOSE记录容器预期使用的端口,不会自动映射主机端口。运行时publish把选定主机地址与端口映射到容器端口;多个容器可内部使用同一端口,但同一主机接口上的发布端口不能冲突。连接测试应检查实际映射,不能从Dockerfile端口声明推断外部已可达。
原稿映射示例:docker run -p 8080:8080 kvs;发布范围还需按运行环境配置核对。
这张卡片看不懂?
这张卡片的反馈已满 10 条,暂时无法继续提交。
已有反馈 · 0 / 10 条
还没有人提交反馈。
在整书笔记中的位置
原书出处 · 1 处
- Building a Cloud Native Service · 查看原书依据
Exposing ports is a way of clearly documenting — both to users and to Docker — which ports a container uses. It does not map or open any ports on the host. Ports can be exposed using the EXPOSE keyword in the Dockerfile or the --expose flag to docker run. Publishing ports tells Docker which
参考来源
- 位置:《Cloud Native Go》第05章《Building a Cloud Native Service》(来源项目book-sources;源文件:extracted/Cloud Native Go (Matthew A. Titmus)/_epub-src/OEBPS/ch05.xhtml)
- 结论依据:EXPOSE记录容器预期使用的端口,不会自动映射主机端口。原文相应定义、示例或限制为此结论提供依据;补充纠错与版本边界在正文就近标明。
- 原始内容:Exposing ports is a way of clearly documenting — both to users and to Docker — which ports a container uses. It does not map or open any ports on the host. Ports can be exposed using the EXPOSE keyword in the Dockerfile or the --expose flag to docker run. Publishing ports tells Docker which