Networking from the container's point of view

Published ports
The type of network a container uses, whether it is a bridge, an overlay, a macvlan network, or a custom network plugin, is transparent from within the container. From the container’s point of view, it has a network interface with an IP address, a gateway, a routing table, DNS services, and other networking details (assuming the container is not using the none network driver).
By default, when you create or run a container using docker create or docker run, it does not publish any of its ports to the outside world. To make a port available to services outside of Docker, or to Docker containers which are not connected to the container’s network, use the --publish or -p flag. This creates a firewall rule which maps a container port to a port on the Docker host to the outside world. Here are some examples.

IP address and hostname
By default, the container is assigned an IP address for every Docker network it connects to. The IP address is assigned from the pool assigned to the network, so the Docker daemon effectively acts as a DHCP server for each container. Each network also has a default subnet mask and gateway.
When you connect an existing container to a different network using docker network connect, you can use the --ip or --ip6 flags on that command to specify the container’s IP address on the additional network.
In the same way, a container’s hostname defaults to be the container’s ID in Docker. You can override the hostname using --hostname. When connecting to an existing network using docker network connect, you can use the --alias flag to specify an additional network alias for the container on that network.

DNS services
By default, a container inherits the DNS settings of the host, as defined in the /etc/resolv.conf configuration file. Containers that use the default bridge network get a copy of this file, whereas containers that use a custom network use Docker’s embedded DNS server, which forwards external DNS lookups to the DNS servers configured on the host.
--dns The IP address of a DNS server. To specify multiple DNS servers, use multiple --dns flags. If the container cannot reach any of the IP addresses you specify, Google’s public DNS server 8.8.8.8 is added, so that your container can resolve internet domains.

最新文章

  1. LeetCode-4MedianofTwoSortedArrays(C#)
  2. C# 通过反射类动态调用DLL方法
  3. Razor 视图引擎 – ASP.NET MVC 4 系列
  4. Linux学习笔记2_mysql安装
  5. Scalaz(38)- Free :Coproduct-Monadic语句组合
  6. document.readyState等属性
  7. gets(),fgets()的作用机制探究
  8. java 读写JSON(一)
  9. HBASE架构解析(一)
  10. Android_Chronometer计时器
  11. UNION 和UNION ALL
  12. 在HTML页面中加载js文件和css文件的方法
  13. C# 枚举器
  14. USB OTG原理+ ID 检测原理
  15. C++ SIMD
  16. 初识STM32中的USMART组件
  17. (二 -0) 天猫精灵接入Home Assistant-安装MQTT服务器
  18. Luogu4547 THUWC2017 随机二分图 概率、状压DP
  19. python 全栈开发,Day102(支付宝支付)
  20. CF1129C Morse Code

热门文章

  1. 通过Camtasia来添加各种各样的光标效果
  2. python中eval()和json.loads的区别
  3. recovery.sh
  4. 日期选择组件(DatePicker)的实现
  5. LaTeX中的插图
  6. wirshark找不到本地接口
  7. 【NOIP2015模拟11.5】JZOJ8月5日提高组T3 旅行
  8. python核心高级学习总结7---------正则表达式
  9. 第2.2节 Python的语句
  10. 第14.15节 爬虫实战1:使用Python和selenium实现csdn博文点赞