zoukankan      html  css  js  c++  java
  • Networking from the container's point of view 笔记

    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.

  • 相关阅读:
    C语言之基本算法24—黄金切割法求方程近似根
    windows下PHP不能开启pgsql扩展的解决方法
    Linux 文件基本属性
    Android倒计时功能的实现
    hdu2444The Accomodation of Students (最大匹配+推断是否为二分图)
    Asp.net core使用IIS在windows上进行托管
    [Asp.net]web.config customErrors 如何设置?
    [Asp.net mvc]Html.ValidationSummary(bool)
    [C#基础]说说lock到底锁谁?(补充与修改)
    [web.config]如何灵活使用配置文件
  • 原文地址:https://www.cnblogs.com/andycja/p/14165111.html
Copyright © 2011-2022 走看看