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

本文共 2931 字,大约阅读时间需要 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.

转载地址:http://txhcl.baihongyu.com/

你可能感兴趣的文章
Debugging Maya Plugin(C++) with CodeBlocks in Linux
查看>>
How to backup your blogs on cnblogs
查看>>
利用html5压缩图片,产出base64图片
查看>>
687C: The values you can make
查看>>
CCF NOI1016 计算天数
查看>>
排序算法的时间复杂度
查看>>
含有选择器的 bootstrap菜单
查看>>
11-09笔记图
查看>>
iOS网络编程笔记——Socket编程
查看>>
滚屏加载--无刷新动态加载数据技术的应用
查看>>
ThinkPHP中Widget的两种写法及调用
查看>>
(转)Linux下root密码丢失和运行级别错误的解决办法
查看>>
23种设计模式全解析
查看>>
ROS服务器与客户端
查看>>
Bear and Floodlight 状态压缩DP啊
查看>>
byte在计算机中的存储方式--Double.byteValue()的输出结果思考
查看>>
JavaScript高级程序设计:第四章
查看>>
关于TP出现_STORAGE_WRITE_ERROR_的解决方案
查看>>
数据库反范式~有时候多点冗余是好事!
查看>>
Android 屏幕适配相关文章
查看>>