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.

  • 相关阅读:
    CGI, FCGI, SCGI, WSGI 释异
    Boa Web Server 缺陷报告及其修正方法
    2.1 linux C 进程与多线程入门--(1)进程和程序的区别
    利用socket实现双机通信
    1、进程管理
    第一章:进程与线程总结
    8、linux网络编程--多播
    6、linux网络编程--UDP协议编程
    7、linux网络编程--广播
    4、linux网络编程--套接字的介绍
  • 原文地址:https://www.cnblogs.com/andycja/p/14165111.html
Copyright © 2011-2022 走看看