docker官方文档中的dns,link,expose,publish

简介: link是过时的了,尽量不要用。 dns内部集成,也可以用外部。 expose只是用于记录,并不真的。 publish是否起作用,也要看情况,是否被占用端口。 --------------------------------------   Embedded DNS server Do...

link是过时的了,尽量不要用。

dns内部集成,也可以用外部。

expose只是用于记录,并不真的。

publish是否起作用,也要看情况,是否被占用端口。

--------------------------------------

 

Embedded DNS server

Docker daemon runs an embedded DNS server which provides DNS resolution among containers connected to the same user-defined network, so that these containers can resolve container names to IP addresses. If the embedded DNS server is unable to resolve the request, it will be forwarded to any external DNS servers configured for the container. To facilitate this when the container is created, only the embedded DNS server reachable at 127.0.0.11 will be listed in the container’s resolv.conf file. For more information on embedded DNS server on user-defined networks, see embedded DNS server in user-defined networks

Exposing and publishing ports

In Docker networking, there are two different mechanisms that directly involve network ports: exposing and publishing ports. This applies to the default bridge network and user-defined bridge networks.

  • You expose ports using the EXPOSE keyword in the Dockerfile or the --expose flag to docker run. Exposing ports is a way of documenting which ports are used, but does not actually map or open any ports. Exposing ports is optional.
  • You publish ports using the PUBLISH keyword in the Dockerfile or the --publish flag to docker run. This tells Docker which ports to open on the container’s network interface. When a port is published, it is mapped to an available high-order port (higher than 30000) on the host machine, unless you specify the port to map to on the host machine at runtime. You cannot specify the port to map to on the host machine in the Dockerfile, because there is no way to guarantee that the port will be available on the host machine where you run the image.

    This example publishes port 80 in the container to a random high port (in this case, 32768) on the host machine.

    $ docker run -it -p 80 nginx
    
    $ docker ps
    
    64879472feea        nginx               "nginx -g 'daemon ..."   43 hours ago        Up About a minute   443/tcp, 0.0.0.0:32768->80/tcp   blissful_mclean
    
    

    The next example specifies that port 80 should be mapped to port 8080 on the host machine. It will fail if port 8080 is not available.

    $ docker run -it -p 80:8080 nginx
    
    $ docker ps
    
    b9788c7adca3        nginx               "nginx -g 'daemon ..."   43 hours ago        Up 3 seconds        80/tcp, 443/tcp, 0.0.0.0:80->8080/tcp   goofy_brahmagupta
    

Links

Before Docker included user-defined networks, you could use the Docker --link feature to allow a container to resolve another container’s name to an IP address, and also give it access to the linked container’s environment variables. Where possible, you should avoid using the legacy --link flag.

When you create links, they behave differently when you use the default bridge network or when you use user-defined bridge networks. For more information, see Legacy Links for link feature in default bridge network and the linking containers in user-defined networks for links functionality in user-defined networks.

目录
相关文章
|
1月前
|
数据可视化 Linux API
如何在Linux使用docker部署Swagger Editor并实现无公网IP远程协同编辑API文档
如何在Linux使用docker部署Swagger Editor并实现无公网IP远程协同编辑API文档
|
3月前
|
数据可视化 Linux API
使用Docker安装部署Swagger Editor并远程访问编辑API文档
使用Docker安装部署Swagger Editor并远程访问编辑API文档
52 0
|
4月前
|
数据管理 数据库 数据安全/隐私保护
数据管理与持久化:深度解析Docker数据卷
Docker 数据卷在容器化应用中扮演着关键角色,它们提供了一种灵活且可持久化的方式来处理应用数据。本文将深入讨论 Docker 数据卷的基本概念、使用方法以及一系列高级应用场景,通过更为丰富和实际的示例代码,帮助大家全面掌握数据卷的使用和管理。
|
26天前
|
Kubernetes 网络协议 Docker
Docker 容器的DNS
Docker 容器的DNS
28 1
|
1月前
|
SQL Apache 流计算
Apache Flink官方网站提供了关于如何使用Docker进行Flink CDC测试的文档
【2月更文挑战第25天】Apache Flink官方网站提供了关于如何使用Docker进行Flink CDC测试的文档
143 3
|
1月前
|
测试技术 Linux 网络安全
【Docker项目实战】Docker环境下部署docat文档管理系统
【2月更文挑战第18天】Docker环境下部署docat文档管理系统
62 3
|
2月前
|
运维 Java Linux
深入解析:使用Docker容器化技术提升Java应用的部署效率
在快速迭代的软件开发周期中,如何保证应用的快速、一致和可靠部署成为了开发团队需要面对的重大挑战。本文将探讨如何利用Docker容器化技术,结合Java应用,实现高效、一致的部署流程。我们将从Docker的基本概念出发,详细介绍将Java应用容器化的步骤,包括创建Dockerfile、构建镜像以及运行容器等关键环节,并通过示例代码加以说明。此外,本文还将讨论在使用Docker部署Java应用时可能遇到的常见问题及其解决策略,旨在为读者提供一种提升部署效率、优化开发流程的有效方法。
303 2
|
3月前
|
应用服务中间件 nginx Docker
docker系列:dockerfile及其用法解析
docker系列:dockerfile及其用法解析
84 0
|
3月前
|
Kubernetes 网络协议 NoSQL
docker 解析DNS失败
docker 解析DNS失败
36 0
|
4月前
|
安全 应用服务中间件 nginx
Docker基础概念解析:镜像、容器、仓库
当谈到容器化技术时,Docker往往是第一个被提及的工具。Docker的基础概念涵盖了镜像、容器和仓库,它们是理解和使用Docker的关键要素。在这篇文章中,将深入探讨这些概念,并提供更丰富的示例代码,帮助大家更好地理解和应用这些概念。

相关产品

  • 云解析DNS