博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
docker官方文档中的dns,link,expose,publish
阅读量:4309 次
发布时间:2019-06-06

本文共 2981 字,大约阅读时间需要 9 分钟。

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 

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 ps64879472feea        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 psb9788c7adca3        nginx               "nginx -g 'daemon ..."   43 hours ago        Up 3 seconds        80/tcp, 443/tcp, 0.0.0.0:80->8080/tcp   goofy_brahmagupta

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  for link feature in default bridge network and the  for links functionality in user-defined networks.

转载于:https://www.cnblogs.com/aguncn/p/6880525.html

你可能感兴趣的文章
vim7.1在windows下的编码设置[转]
查看>>
同步器之Exchanger
查看>>
IO流
查看>>
专家观点:即使在云中 硬件同样至关重要
查看>>
loadrunner11录制不成功解决方法(收集)
查看>>
jQuery 基础
查看>>
USE平台构件属性无法显示的一种解决办法
查看>>
Cannot open include file: jni.h: No such file or directory解决方法
查看>>
HDU-水饺基情 二维树状数组
查看>>
visual studio 安装Entity framework失败
查看>>
测试对bug如何分析和定位
查看>>
c/c++学习书籍
查看>>
python应用-爬取猫眼电影top100
查看>>
HC-05蓝牙模块基本使用
查看>>
phper必知必会之类库自动加载的七种方式(三)
查看>>
ansible模块介绍
查看>>
NOIP201307货车运输
查看>>
齐次坐标
查看>>
[SQLite]使用记录
查看>>
HttpRequest 类
查看>>