成人性生交大片免费看视频r_亚洲综合极品香蕉久久网_在线视频免费观看一区_亚洲精品亚洲人成人网在线播放_国产精品毛片av_久久久久国产精品www_亚洲国产一区二区三区在线播_日韩一区二区三区四区区区_亚洲精品国产无套在线观_国产免费www

主頁 > 知識(shí)庫 > Docker網(wǎng)絡(luò)原理及自定義網(wǎng)絡(luò)詳細(xì)解析

Docker網(wǎng)絡(luò)原理及自定義網(wǎng)絡(luò)詳細(xì)解析

熱門標(biāo)簽:打400電話怎么辦理收費(fèi) 麗江真人語音電話外呼系統(tǒng) 宿城區(qū)電話機(jī)器人找哪家 上海申請(qǐng)高400開頭的電話 400電話辦理介紹信 怎么找到?jīng)]有地圖標(biāo)注的店 10086外包用的什么外呼系統(tǒng) 河南防封號(hào)電銷機(jī)器人是什么 福州企業(yè)電銷機(jī)器人排名

Docker在宿主機(jī)上虛擬了一個(gè)網(wǎng)橋,當(dāng)創(chuàng)建并啟動(dòng)容器的時(shí)候,每一個(gè)容器默認(rèn)都會(huì)被分配一個(gè)跟網(wǎng)橋網(wǎng)段一致的ip,網(wǎng)橋作為容器的網(wǎng)關(guān),網(wǎng)橋與每一個(gè)容器聯(lián)通,容器間通過網(wǎng)橋可以通信。由于網(wǎng)橋是虛擬出來的,外網(wǎng)無法進(jìn)行尋址,也就是默認(rèn)外網(wǎng)無法訪問容器,需要在創(chuàng)建啟動(dòng)容器時(shí)把宿主機(jī)的端口與容器端口進(jìn)行映射,通過宿主機(jī)IP端口訪問容器。這是Docker默認(rèn)的網(wǎng)絡(luò),它有一個(gè)弊端是只能通過IP讓容器互相訪問,如果想使用容器名稱或容器ID互相訪問需要在創(chuàng)建啟動(dòng)容器時(shí)候用link的方式修改hosts文件實(shí)現(xiàn)。一般使用自定義網(wǎng)絡(luò),自定義網(wǎng)絡(luò)使用network創(chuàng)建,創(chuàng)建時(shí)可以指定子網(wǎng)網(wǎng)段及網(wǎng)關(guān)等信息,在創(chuàng)建并啟動(dòng)容器時(shí)指定使用的網(wǎng)絡(luò)。這樣在一個(gè)自定義網(wǎng)絡(luò)里的所有容器可以直接使用容器名進(jìn)行訪問,如果一個(gè)容器想要訪問其他網(wǎng)絡(luò)中的容器也可以在network中進(jìn)行設(shè)置,這樣這個(gè)容器與目標(biāo)網(wǎng)絡(luò)的容器可以使用容器名通信。

1 默認(rèn)網(wǎng)絡(luò)docker0

用vm虛擬機(jī)測(cè)試,未啟動(dòng)docker 系統(tǒng)中有兩個(gè)網(wǎng)絡(luò)(回環(huán)網(wǎng)絡(luò)、虛擬機(jī)網(wǎng)絡(luò))

當(dāng)啟動(dòng)docker服務(wù)后,宿主機(jī)多出一個(gè)網(wǎng)絡(luò)docker0 這就是docker默認(rèn)網(wǎng)絡(luò)

# 啟動(dòng)docker服務(wù)
[root@localhost ~]# systemctl start docker

啟動(dòng)一個(gè)tomcat容器,會(huì)發(fā)現(xiàn)宿主機(jī)又多出一個(gè)網(wǎng)絡(luò)

啟動(dòng)tomcat
[root@localhost ~]# docker run -d -P --name tomcat1 tomcat

再啟動(dòng)一個(gè)tomcat,會(huì)發(fā)展宿主機(jī)又多出一個(gè)網(wǎng)絡(luò)

# 啟動(dòng)tomcat
[root@localhost ~]# docker run -d -P --name tomcat2 tomcat

測(cè)試兩個(gè)tomcat網(wǎng)絡(luò)ip是通的

# 查看tomcat的ip地址
[root@localhost ~]# docker exec -it tomcat2 ip addr
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
       valid_lft forever preferred_lft forever
9: eth0@if10: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP group default
    link/ether 02:42:ac:11:00:03 brd ff:ff:ff:ff:ff:ff link-netnsid 0
    inet 172.17.0.3/16 brd 172.17.255.255 scope global eth0
       valid_lft forever preferred_lft forever
# 在tomcat1 ping tomcat2的ip
[root@localhost ~]# docker exec -it tomcat1 ping 172.17.0.3
PING 172.17.0.3 (172.17.0.3) 56(84) bytes of data.
64 bytes from 172.17.0.3: icmp_seq=1 ttl=64 time=0.146 ms
64 bytes from 172.17.0.3: icmp_seq=2 ttl=64 time=0.067 ms
64 bytes from 172.17.0.3: icmp_seq=3 ttl=64 time=0.088 ms
^C
--- 172.17.0.3 ping statistics ---
3 packets transmitted, 3 received, 0% packet loss, time 5ms
rtt min/avg/max/mdev = 0.067/0.100/0.146/0.034 ms

在tomcat1里ping tomcat2的 容器名無法ping通

# 在tomcat1里ping tomcat2的容器名
[root@localhost ~]# docker exec -it tomcat1 ping tomcat2
^C[root@localhost ~]#

停止tomcat1 重新創(chuàng)建啟動(dòng)tomcat 使用link 會(huì)在底層修改tomcat1 的hosts文件 實(shí)現(xiàn)容器名作為ip域名從而tomcat1到tomcat2的單向ping通

# 刪除tomcat1
[root@localhost ~]# docker rm -f tomcat1
tomcat1
 
# 查看run的幫助文檔 link用法
[root@localhost ~]# docker run --help
 
Usage:  docker run [OPTIONS] IMAGE [COMMAND] [ARG...]
 
Run a command in a new container
 
Options:
      --add-host list                  Add a custom host-to-IP mapping (host:ip)
  -a, --attach list                    Attach to STDIN, STDOUT or STDERR
      --blkio-weight uint16            Block IO (relative weight), between 10 and 1000, or 0 to disable (default 0)
      --blkio-weight-device list       Block IO weight (relative device weight) (default [])
      --cap-add list                   Add Linux capabilities
      --cap-drop list                  Drop Linux capabilities
      --cgroup-parent string           Optional parent cgroup for the container
      --cgroupns string                Cgroup namespace to use (host|private)
                                       'host':    Run the container in the Docker host's cgroup namespace
                                       'private': Run the container in its own private cgroup namespace
                                       '':        Use the cgroup namespace as configured by the
                                                  default-cgroupns-mode option on the daemon (default)
      --cidfile string                 Write the container ID to the file
      --cpu-period int                 Limit CPU CFS (Completely Fair Scheduler) period
      --cpu-quota int                  Limit CPU CFS (Completely Fair Scheduler) quota
      --cpu-rt-period int              Limit CPU real-time period in microseconds
      --cpu-rt-runtime int             Limit CPU real-time runtime in microseconds
  -c, --cpu-shares int                 CPU shares (relative weight)
      --cpus decimal                   Number of CPUs
      --cpuset-cpus string             CPUs in which to allow execution (0-3, 0,1)
      --cpuset-mems string             MEMs in which to allow execution (0-3, 0,1)
  -d, --detach                         Run container in background and print container ID
      --detach-keys string             Override the key sequence for detaching a container
      --device list                    Add a host device to the container
      --device-cgroup-rule list        Add a rule to the cgroup allowed devices list
      --device-read-bps list           Limit read rate (bytes per second) from a device (default [])
      --device-read-iops list          Limit read rate (IO per second) from a device (default [])
      --device-write-bps list          Limit write rate (bytes per second) to a device (default [])
      --device-write-iops list         Limit write rate (IO per second) to a device (default [])
      --disable-content-trust          Skip image verification (default true)
      --dns list                       Set custom DNS servers
      --dns-option list                Set DNS options
      --dns-search list                Set custom DNS search domains
      --domainname string              Container NIS domain name
      --entrypoint string              Overwrite the default ENTRYPOINT of the image
  -e, --env list                       Set environment variables
      --env-file list                  Read in a file of environment variables
      --expose list                    Expose a port or a range of ports
      --gpus gpu-request               GPU devices to add to the container ('all' to pass all GPUs)
      --group-add list                 Add additional groups to join
      --health-cmd string              Command to run to check health
      --health-interval duration       Time between running the check (ms|s|m|h) (default 0s)
      --health-retries int             Consecutive failures needed to report unhealthy
      --health-start-period duration   Start period for the container to initialize before starting health-retries countdown
                                       (ms|s|m|h) (default 0s)
      --health-timeout duration        Maximum time to allow one check to run (ms|s|m|h) (default 0s)
      --help                           Print usage
  -h, --hostname string                Container host name
      --init                           Run an init inside the container that forwards signals and reaps processes
  -i, --interactive                    Keep STDIN open even if not attached
      --ip string                      IPv4 address (e.g., 172.30.100.104)
      --ip6 string                     IPv6 address (e.g., 2001:db8::33)
      --ipc string                     IPC mode to use
      --isolation string               Container isolation technology
      --kernel-memory bytes            Kernel memory limit
  -l, --label list                     Set meta data on a container
      --label-file list                Read in a line delimited file of labels
      --link list                      Add link to another container
      --link-local-ip list             Container IPv4/IPv6 link-local addresses
      --log-driver string              Logging driver for the container
      --log-opt list                   Log driver options
      --mac-address string             Container MAC address (e.g., 92:d0:c6:0a:29:33)
  -m, --memory bytes                   Memory limit
      --memory-reservation bytes       Memory soft limit
      --memory-swap bytes              Swap limit equal to memory plus swap: '-1' to enable unlimited swap
      --memory-swappiness int          Tune container memory swappiness (0 to 100) (default -1)
      --mount mount                    Attach a filesystem mount to the container
      --name string                    Assign a name to the container
      --network network                Connect a container to a network
      --network-alias list             Add network-scoped alias for the container
      --no-healthcheck                 Disable any container-specified HEALTHCHECK
      --oom-kill-disable               Disable OOM Killer
      --oom-score-adj int              Tune host's OOM preferences (-1000 to 1000)
      --pid string                     PID namespace to use
      --pids-limit int                 Tune container pids limit (set -1 for unlimited)
      --platform string                Set platform if server is multi-platform capable
      --privileged                     Give extended privileges to this container
  -p, --publish list                   Publish a container's port(s) to the host
  -P, --publish-all                    Publish all exposed ports to random ports
      --pull string                    Pull image before running ("always"|"missing"|"never") (default "missing")
      --read-only                      Mount the container's root filesystem as read only
      --restart string                 Restart policy to apply when a container exits (default "no")
      --rm                             Automatically remove the container when it exits
      --runtime string                 Runtime to use for this container
      --security-opt list              Security Options
      --shm-size bytes                 Size of /dev/shm
      --sig-proxy                      Proxy received signals to the process (default true)
      --stop-signal string             Signal to stop a container (default "SIGTERM")
      --stop-timeout int               Timeout (in seconds) to stop a container
      --storage-opt list               Storage driver options for the container
      --sysctl map                     Sysctl options (default map[])
      --tmpfs list                     Mount a tmpfs directory
  -t, --tty                            Allocate a pseudo-TTY
      --ulimit ulimit                  Ulimit options (default [])
  -u, --user string                    Username or UID (format: <name|uid>[:<group|gid>])
      --userns string                  User namespace to use
      --uts string                     UTS namespace to use
  -v, --volume list                    Bind mount a volume
      --volume-driver string           Optional volume driver for the container
      --volumes-from list              Mount volumes from the specified container(s)
  -w, --workdir string                 Working directory inside the container
 
# 啟動(dòng)tomcat1 link指定要訪問的容器名
[root@localhost ~]# docker run -d -P --name tomcat1 --link tomcat2 tomcat
f78c51961662a1d3558fc8d0d95906b902a7a042f251a60858e72bcfa62e7a08
 
# 測(cè)試ping
[root@localhost ~]# docker exec -it tomcat1 ping tomcat2
PING tomcat2 (172.17.0.3) 56(84) bytes of data.
64 bytes from tomcat2 (172.17.0.3): icmp_seq=1 ttl=64 time=0.088 ms
64 bytes from tomcat2 (172.17.0.3): icmp_seq=2 ttl=64 time=0.071 ms
64 bytes from tomcat2 (172.17.0.3): icmp_seq=3 ttl=64 time=0.071 ms
^C
--- tomcat2 ping statistics ---
3 packets transmitted, 3 received, 0% packet loss, time 1000ms
rtt min/avg/max/mdev = 0.071/0.076/0.088/0.012 ms
 
# 查看tomcat1的hosts已經(jīng)加入了tomcat2的域名
[root@localhost ~]# docker exec -it tomcat1 cat /etc/hosts
127.0.0.1       localhost
::1     localhost ip6-localhost ip6-loopback
fe00::0 ip6-localnet
ff00::0 ip6-mcastprefix
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters
172.17.0.3      tomcat2 27766c324de6
172.17.0.2      f78c51961662
 
# tomcat2無法ping通tomcat1
[root@localhost ~]# docker exec -it tomcat2 ping tomcat1
^C[root@localhost ~]#

2 自定義網(wǎng)絡(luò)

需要用到network命令

# 查看幫助文檔
[root@localhost ~]# docker network --help
 
Usage:  docker network COMMAND
 
Manage networks
 
Commands:
  connect     Connect a container to a network
  create      Create a network
  disconnect  Disconnect a container from a network
  inspect     Display detailed information on one or more networks
  ls          List networks
  prune       Remove all unused networks
  rm          Remove one or more networks
 
Run 'docker network COMMAND --help' for more information on a command.

列出當(dāng)前的docker網(wǎng)絡(luò) bridge為 默認(rèn)網(wǎng)絡(luò)docker0

[root@localhost ~]# docker network ls
NETWORK ID     NAME      DRIVER    SCOPE
9b27ff0926bf   bridge    bridge    local
8dfa2efae677   host      host      local
2025b7fb1d7c   none      null      local

創(chuàng)建網(wǎng)絡(luò)mynet

[root@localhost ~]# docker network create --help
 
Usage:  docker network create [OPTIONS] NETWORK
 
Create a network
 
Options:
      --attachable           Enable manual container attachment
      --aux-address map      Auxiliary IPv4 or IPv6 addresses used by Network driver (default map[])
      --config-from string   The network from which to copy the configuration
      --config-only          Create a configuration only network
  -d, --driver string        Driver to manage the Network (default "bridge")
      --gateway strings      IPv4 or IPv6 Gateway for the master subnet
      --ingress              Create swarm routing-mesh network
      --internal             Restrict external access to the network
      --ip-range strings     Allocate container ip from a sub-range
      --ipam-driver string   IP Address Management Driver (default "default")
      --ipam-opt map         Set IPAM driver specific options (default map[])
      --ipv6                 Enable IPv6 networking
      --label list           Set metadata on a network
  -o, --opt map              Set driver specific options (default map[])
      --scope string         Control the network's scope
      --subnet strings       Subnet in CIDR format that represents a network segment
[root@localhost ~]# docker network create --driver bridge --subnet 192.168.0.0/16 --gateway 192.168.0.1 mynet
1abaa8e6a387bc8bbc7ac50d9f2289e96a143a92f074e90f698bd70411c86672
[root@localhost ~]# docker network inspect mynet
[
    {
        "Name": "mynet",
        "Id": "1abaa8e6a387bc8bbc7ac50d9f2289e96a143a92f074e90f698bd70411c86672",
        "Created": "2021-05-13T11:21:13.494039122+08:00",
        "Scope": "local",
        "Driver": "bridge",
        "EnableIPv6": false,
        "IPAM": {
            "Driver": "default",
            "Options": {},
            "Config": [
                {
                    "Subnet": "192.168.0.0/16",
                    "Gateway": "192.168.0.1"
                }
            ]
        },
        "Internal": false,
        "Attachable": false,
        "Ingress": false,
        "ConfigFrom": {
            "Network": ""
        },
        "ConfigOnly": false,
        "Containers": {},
        "Options": {},
        "Labels": {}
    }
]

使用mynet創(chuàng)建啟動(dòng)兩個(gè)tomcat,他們可以直接通過容器名稱雙向互相ping通

[root@localhost ~]# docker run --help
 
Usage:  docker run [OPTIONS] IMAGE [COMMAND] [ARG...]
 
Run a command in a new container
 
Options:
      --add-host list                  Add a custom host-to-IP mapping (host:ip)
  -a, --attach list                    Attach to STDIN, STDOUT or STDERR
      --blkio-weight uint16            Block IO (relative weight), between 10 and 1000, or 0 to disable (default 0)
      --blkio-weight-device list       Block IO weight (relative device weight) (default [])
      --cap-add list                   Add Linux capabilities
      --cap-drop list                  Drop Linux capabilities
      --cgroup-parent string           Optional parent cgroup for the container
      --cgroupns string                Cgroup namespace to use (host|private)
                                       'host':    Run the container in the Docker host's cgroup namespace
                                       'private': Run the container in its own private cgroup namespace
                                       '':        Use the cgroup namespace as configured by the
                                                  default-cgroupns-mode option on the daemon (default)
      --cidfile string                 Write the container ID to the file
      --cpu-period int                 Limit CPU CFS (Completely Fair Scheduler) period
      --cpu-quota int                  Limit CPU CFS (Completely Fair Scheduler) quota
      --cpu-rt-period int              Limit CPU real-time period in microseconds
      --cpu-rt-runtime int             Limit CPU real-time runtime in microseconds
  -c, --cpu-shares int                 CPU shares (relative weight)
      --cpus decimal                   Number of CPUs
      --cpuset-cpus string             CPUs in which to allow execution (0-3, 0,1)
      --cpuset-mems string             MEMs in which to allow execution (0-3, 0,1)
  -d, --detach                         Run container in background and print container ID
      --detach-keys string             Override the key sequence for detaching a container
      --device list                    Add a host device to the container
      --device-cgroup-rule list        Add a rule to the cgroup allowed devices list
      --device-read-bps list           Limit read rate (bytes per second) from a device (default [])
      --device-read-iops list          Limit read rate (IO per second) from a device (default [])
      --device-write-bps list          Limit write rate (bytes per second) to a device (default [])
      --device-write-iops list         Limit write rate (IO per second) to a device (default [])
      --disable-content-trust          Skip image verification (default true)
      --dns list                       Set custom DNS servers
      --dns-option list                Set DNS options
      --dns-search list                Set custom DNS search domains
      --domainname string              Container NIS domain name
      --entrypoint string              Overwrite the default ENTRYPOINT of the image
  -e, --env list                       Set environment variables
      --env-file list                  Read in a file of environment variables
      --expose list                    Expose a port or a range of ports
      --gpus gpu-request               GPU devices to add to the container ('all' to pass all GPUs)
      --group-add list                 Add additional groups to join
      --health-cmd string              Command to run to check health
      --health-interval duration       Time between running the check (ms|s|m|h) (default 0s)
      --health-retries int             Consecutive failures needed to report unhealthy
      --health-start-period duration   Start period for the container to initialize before starting health-retries countdown
                                       (ms|s|m|h) (default 0s)
      --health-timeout duration        Maximum time to allow one check to run (ms|s|m|h) (default 0s)
      --help                           Print usage
  -h, --hostname string                Container host name
      --init                           Run an init inside the container that forwards signals and reaps processes
  -i, --interactive                    Keep STDIN open even if not attached
      --ip string                      IPv4 address (e.g., 172.30.100.104)
      --ip6 string                     IPv6 address (e.g., 2001:db8::33)
      --ipc string                     IPC mode to use
      --isolation string               Container isolation technology
      --kernel-memory bytes            Kernel memory limit
  -l, --label list                     Set meta data on a container
      --label-file list                Read in a line delimited file of labels
      --link list                      Add link to another container
      --link-local-ip list             Container IPv4/IPv6 link-local addresses
      --log-driver string              Logging driver for the container
      --log-opt list                   Log driver options
      --mac-address string             Container MAC address (e.g., 92:d0:c6:0a:29:33)
  -m, --memory bytes                   Memory limit
      --memory-reservation bytes       Memory soft limit
      --memory-swap bytes              Swap limit equal to memory plus swap: '-1' to enable unlimited swap
      --memory-swappiness int          Tune container memory swappiness (0 to 100) (default -1)
      --mount mount                    Attach a filesystem mount to the container
      --name string                    Assign a name to the container
      --network network                Connect a container to a network
      --network-alias list             Add network-scoped alias for the container
      --no-healthcheck                 Disable any container-specified HEALTHCHECK
      --oom-kill-disable               Disable OOM Killer
      --oom-score-adj int              Tune host's OOM preferences (-1000 to 1000)
      --pid string                     PID namespace to use
      --pids-limit int                 Tune container pids limit (set -1 for unlimited)
      --platform string                Set platform if server is multi-platform capable
      --privileged                     Give extended privileges to this container
  -p, --publish list                   Publish a container's port(s) to the host
  -P, --publish-all                    Publish all exposed ports to random ports
      --pull string                    Pull image before running ("always"|"missing"|"never") (default "missing")
      --read-only                      Mount the container's root filesystem as read only
      --restart string                 Restart policy to apply when a container exits (default "no")
      --rm                             Automatically remove the container when it exits
      --runtime string                 Runtime to use for this container
      --security-opt list              Security Options
      --shm-size bytes                 Size of /dev/shm
      --sig-proxy                      Proxy received signals to the process (default true)
      --stop-signal string             Signal to stop a container (default "SIGTERM")
      --stop-timeout int               Timeout (in seconds) to stop a container
      --storage-opt list               Storage driver options for the container
      --sysctl map                     Sysctl options (default map[])
      --tmpfs list                     Mount a tmpfs directory
  -t, --tty                            Allocate a pseudo-TTY
      --ulimit ulimit                  Ulimit options (default [])
  -u, --user string                    Username or UID (format: <name|uid>[:<group|gid>])
      --userns string                  User namespace to use
      --uts string                     UTS namespace to use
  -v, --volume list                    Bind mount a volume
      --volume-driver string           Optional volume driver for the container
      --volumes-from list              Mount volumes from the specified container(s)
  -w, --workdir string                 Working directory inside the container
[root@localhost ~]# docker run -d -P --name tomcat-n-1 --network mynet tomcat
404e4e63622b207af2ed534e768996f4d1cba4c798bba9e5d9b33c42711eaa4a
[root@localhost ~]# docker run -d -P --name tomcat-n-2 --network mynet tomcat
f6352fb3db01beed6ddf17ef84999a4ab209f026a6137b3bc7e35335d434785f
[root@localhost ~]# docker ps
CONTAINER ID   IMAGE     COMMAND             CREATED          STATUS          PORTS                                         NAMES
f6352fb3db01   tomcat    "catalina.sh run"   3 seconds ago    Up 2 seconds    0.0.0.0:49159->8080/tcp, :::49159->8080/tcp   tomcat-n-2
404e4e63622b   tomcat    "catalina.sh run"   10 seconds ago   Up 9 seconds    0.0.0.0:49158->8080/tcp, :::49158->8080/tcp   tomcat-n-1
f78c51961662   tomcat    "catalina.sh run"   15 minutes ago   Up 15 minutes   0.0.0.0:49157->8080/tcp, :::49157->8080/tcp   tomcat1
27766c324de6   tomcat    "catalina.sh run"   16 minutes ago   Up 16 minutes   0.0.0.0:49156->8080/tcp, :::49156->8080/tcp   tomcat2
[root@localhost ~]# docker exec -it tomcat-n-1 ping tomcat-n-2
PING tomcat-n-2 (192.168.0.3) 56(84) bytes of data.
64 bytes from tomcat-n-2.mynet (192.168.0.3): icmp_seq=1 ttl=64 time=0.102 ms
64 bytes from tomcat-n-2.mynet (192.168.0.3): icmp_seq=2 ttl=64 time=0.069 ms
64 bytes from tomcat-n-2.mynet (192.168.0.3): icmp_seq=3 ttl=64 time=0.164 ms
^C
--- tomcat-n-2 ping statistics ---
3 packets transmitted, 3 received, 0% packet loss, time 3ms
rtt min/avg/max/mdev = 0.069/0.111/0.164/0.041 ms

查看mynet網(wǎng)絡(luò)的詳細(xì)信息,包含了啟動(dòng)的兩個(gè)tomcat容器的網(wǎng)絡(luò)信息

[root@localhost ~]# docker network inspect mynet
[
    {
        "Name": "mynet",
        "Id": "1abaa8e6a387bc8bbc7ac50d9f2289e96a143a92f074e90f698bd70411c86672",
        "Created": "2021-05-13T11:21:13.494039122+08:00",
        "Scope": "local",
        "Driver": "bridge",
        "EnableIPv6": false,
        "IPAM": {
            "Driver": "default",
            "Options": {},
            "Config": [
                {
                    "Subnet": "192.168.0.0/16",
                    "Gateway": "192.168.0.1"
                }
            ]
        },
        "Internal": false,
        "Attachable": false,
        "Ingress": false,
        "ConfigFrom": {
            "Network": ""
        },
        "ConfigOnly": false,
        "Containers": {
            "404e4e63622b207af2ed534e768996f4d1cba4c798bba9e5d9b33c42711eaa4a": {
                "Name": "tomcat-n-1",
                "EndpointID": "b9efbd78daabe9345ade2a2e55291b7646d01679516e2f0be1efd5c2d6fea6b8",
                "MacAddress": "02:42:c0:a8:00:02",
                "IPv4Address": "192.168.0.2/16",
                "IPv6Address": ""
            },
            "f6352fb3db01beed6ddf17ef84999a4ab209f026a6137b3bc7e35335d434785f": {
                "Name": "tomcat-n-2",
                "EndpointID": "6b05a1ceff43514305bf3d0adf9e30ba8007db5ec8349d47f96ff2b216912fc0",
                "MacAddress": "02:42:c0:a8:00:03",
                "IPv4Address": "192.168.0.3/16",
                "IPv6Address": ""
            }
        },
        "Options": {},
        "Labels": {}
    }
]

啟動(dòng)一個(gè)tomcat3使用默認(rèn)網(wǎng)絡(luò)docker0

[root@localhost ~]# docker run -d -P --name tomcat3 tomcat
90e94ac30a3c61b493d2ea38c32cf5dddb781e88c30547b609db765b15d7d1e0
[root@localhost ~]# docker network ls
NETWORK ID     NAME      DRIVER    SCOPE
9b27ff0926bf   bridge    bridge    local
8dfa2efae677   host      host      local
1abaa8e6a387   mynet     bridge    local
2025b7fb1d7c   none      null      local
 
# 查看docker0詳細(xì)信息 tomcat3出現(xiàn)在默認(rèn)網(wǎng)絡(luò)里
[root@localhost ~]# docker network inspect 9b27ff0926bf
[
    {
        "Name": "bridge",
        "Id": "9b27ff0926bf22d0828ccd07d6e14eb17d96a4989f9def6f9118c099cf1ca1c6",
        "Created": "2021-05-13T10:51:20.244232273+08:00",
        "Scope": "local",
        "Driver": "bridge",
        "EnableIPv6": false,
        "IPAM": {
            "Driver": "default",
            "Options": null,
            "Config": [
                {
                    "Subnet": "172.17.0.0/16",
                    "Gateway": "172.17.0.1"
                }
            ]
        },
        "Internal": false,
        "Attachable": false,
        "Ingress": false,
        "ConfigFrom": {
            "Network": ""
        },
        "ConfigOnly": false,
        "Containers": {
            "27766c324de619b24e2ed522d8064c5a4610c8f509ff0aed8fa1719691f01bf1": {
                "Name": "tomcat2",
                "EndpointID": "de913778ce2d7478e25daca26809aa75c9093c43853d9420c70886fb16741722",
                "MacAddress": "02:42:ac:11:00:03",
                "IPv4Address": "172.17.0.3/16",
                "IPv6Address": ""
            },
            "90e94ac30a3c61b493d2ea38c32cf5dddb781e88c30547b609db765b15d7d1e0": {
                "Name": "tomcat3",
                "EndpointID": "2223e522a0950b846bb7691b31f60bbd88ab3c9b8e71d601a495cce39387b8cc",
                "MacAddress": "02:42:ac:11:00:04",
                "IPv4Address": "172.17.0.4/16",
                "IPv6Address": ""
            },
            "f78c51961662a1d3558fc8d0d95906b902a7a042f251a60858e72bcfa62e7a08": {
                "Name": "tomcat1",
                "EndpointID": "59299fdca5497e55dc5a94e408529cc98819b673568720c81aa1c554dff1bbe5",
                "MacAddress": "02:42:ac:11:00:02",
                "IPv4Address": "172.17.0.2/16",
                "IPv6Address": ""
            }
        },
        "Options": {
            "com.docker.network.bridge.default_bridge": "true",
            "com.docker.network.bridge.enable_icc": "true",
            "com.docker.network.bridge.enable_ip_masquerade": "true",
            "com.docker.network.bridge.host_binding_ipv4": "0.0.0.0",
            "com.docker.network.bridge.name": "docker0",
            "com.docker.network.driver.mtu": "1500"
        },
        "Labels": {}
    }
]

tomcat3和mynet不在一個(gè)網(wǎng)絡(luò),tomcat3無法訪問mynet網(wǎng)絡(luò)里的兩個(gè)tomcat,可以使用network打通tomcat3和mynetwork,實(shí)現(xiàn)雙向互相訪問(支持容器名稱)。

# 查看mynet網(wǎng)絡(luò)里容器的ip
[root@localhost ~]# docker network inspect mynet
[
    {
        "Name": "mynet",
        "Id": "1abaa8e6a387bc8bbc7ac50d9f2289e96a143a92f074e90f698bd70411c86672",
        "Created": "2021-05-13T11:21:13.494039122+08:00",
        "Scope": "local",
        "Driver": "bridge",
        "EnableIPv6": false,
        "IPAM": {
            "Driver": "default",
            "Options": {},
            "Config": [
                {
                    "Subnet": "192.168.0.0/16",
                    "Gateway": "192.168.0.1"
                }
            ]
        },
        "Internal": false,
        "Attachable": false,
        "Ingress": false,
        "ConfigFrom": {
            "Network": ""
        },
        "ConfigOnly": false,
        "Containers": {
            "404e4e63622b207af2ed534e768996f4d1cba4c798bba9e5d9b33c42711eaa4a": {
                "Name": "tomcat-n-1",
                "EndpointID": "b9efbd78daabe9345ade2a2e55291b7646d01679516e2f0be1efd5c2d6fea6b8",
                "MacAddress": "02:42:c0:a8:00:02",
                "IPv4Address": "192.168.0.2/16",
                "IPv6Address": ""
            },
            "f6352fb3db01beed6ddf17ef84999a4ab209f026a6137b3bc7e35335d434785f": {
                "Name": "tomcat-n-2",
                "EndpointID": "6b05a1ceff43514305bf3d0adf9e30ba8007db5ec8349d47f96ff2b216912fc0",
                "MacAddress": "02:42:c0:a8:00:03",
                "IPv4Address": "192.168.0.3/16",
                "IPv6Address": ""
            }
        },
        "Options": {},
        "Labels": {}
    }
]
 
# tomcat3 ping ip不通
[root@localhost ~]# docker exec -it tomcat3 ping 192.168.0.2
PING 192.168.0.2 (192.168.0.2) 56(84) bytes of data.
^C
--- 192.168.0.2 ping statistics ---
7 packets transmitted, 0 received, 100% packet loss, time 11ms
 
[root@localhost ~]# docker exec -it tomcat3 ping 192.168.0.3
PING 192.168.0.3 (192.168.0.3) 56(84) bytes of data.
^C
--- 192.168.0.3 ping statistics ---
9 packets transmitted, 0 received, 100% packet loss, time 20ms
# 使用connect聯(lián)通一個(gè)網(wǎng)絡(luò)和另外一個(gè)網(wǎng)絡(luò)里的容器,可以互相容器名稱訪問
[root@localhost ~]# docker network connect --help
 
Usage:  docker network connect [OPTIONS] NETWORK CONTAINER
 
Connect a container to a network
 
Options:
      --alias strings           Add network-scoped alias for the container
      --driver-opt strings      driver options for the network
      --ip string               IPv4 address (e.g., 172.30.100.104)
      --ip6 string              IPv6 address (e.g., 2001:db8::33)
      --link list               Add link to another container
      --link-local-ip strings   Add a link-local address for the container
[root@localhost ~]# docker network connect mynet tomcat3
[root@localhost ~]# docker exec -it tomcat3 ping tomcat-n-1
PING tomcat-n-1 (192.168.0.2) 56(84) bytes of data.
64 bytes from tomcat-n-1.mynet (192.168.0.2): icmp_seq=1 ttl=64 time=0.235 ms
64 bytes from tomcat-n-1.mynet (192.168.0.2): icmp_seq=2 ttl=64 time=0.070 ms
64 bytes from tomcat-n-1.mynet (192.168.0.2): icmp_seq=3 ttl=64 time=0.064 ms
^C
--- tomcat-n-1 ping statistics ---
3 packets transmitted, 3 received, 0% packet loss, time 6ms
rtt min/avg/max/mdev = 0.064/0.123/0.235/0.079 ms
[root@localhost ~]# docker exec -it tomcat-n-1 ping tomcat3
PING tomcat3 (192.168.0.4) 56(84) bytes of data.
64 bytes from tomcat3.mynet (192.168.0.4): icmp_seq=1 ttl=64 time=0.055 ms
64 bytes from tomcat3.mynet (192.168.0.4): icmp_seq=2 ttl=64 time=0.169 ms
64 bytes from tomcat3.mynet (192.168.0.4): icmp_seq=3 ttl=64 time=0.194 ms
^C
--- tomcat3 ping statistics ---
3 packets transmitted, 3 received, 0% packet loss, time 6ms
rtt min/avg/max/mdev = 0.055/0.139/0.194/0.061 ms

以上就是Docker網(wǎng)絡(luò)原理及自定義網(wǎng)絡(luò)詳細(xì)解析的詳細(xì)內(nèi)容,更多關(guān)于docker網(wǎng)絡(luò)原理的資料請(qǐng)關(guān)注腳本之家其它相關(guān)文章!

標(biāo)簽:荊門 面試通知 隴南 連云港 朝陽 遵義 運(yùn)城 雞西

巨人網(wǎng)絡(luò)通訊聲明:本文標(biāo)題《Docker網(wǎng)絡(luò)原理及自定義網(wǎng)絡(luò)詳細(xì)解析》,本文關(guān)鍵詞  Docker,網(wǎng)絡(luò),原理,及,自定義,;如發(fā)現(xiàn)本文內(nèi)容存在版權(quán)問題,煩請(qǐng)?zhí)峁┫嚓P(guān)信息告之我們,我們將及時(shí)溝通與處理。本站內(nèi)容系統(tǒng)采集于網(wǎng)絡(luò),涉及言論、版權(quán)與本站無關(guān)。
  • 相關(guān)文章
  • 下面列出與本文章《Docker網(wǎng)絡(luò)原理及自定義網(wǎng)絡(luò)詳細(xì)解析》相關(guān)的同類信息!
  • 本頁收集關(guān)于Docker網(wǎng)絡(luò)原理及自定義網(wǎng)絡(luò)詳細(xì)解析的相關(guān)信息資訊供網(wǎng)民參考!
  • 推薦文章
    黑人巨大精品欧美一区二区免费| 国产精品久久久久毛片大屁完整版| 国产精品久久777777| 美女高潮黄又色高清视频免费| 日本xxxwww免费视频| 欧美极品少妇videossex| 久久在精品线影院精品国产| 一级片一级片一级片| 中文字幕久久综合| 91色视频在线导航| 亚洲免费国产| 精品亚洲成a人在线观看| 日日躁夜夜躁aaaabbbb| 日本欧美电影在线观看| 欧美精品一区二区三区涩爱蜜| 国产精品资源网站| 亚洲一区二区三区在线视频| 一区二区国产精品精华液| 精产国产伦理一二三区| 亚洲不卡系列| 99国产超薄肉色丝袜交足的后果| 日韩影片在线播放| 成人在线免费观看91| 日日摸夜夜夜夜夜添| 国内成人自拍视频| av黄色在线免费观看| 人人妻人人添人人爽欧美一区| 欧美成人午夜激情在线| 99久久夜色精品国产亚洲1000部| 国产又粗又猛又爽又黄的| 日本韩国一区二区三区视频| 国产精品美女久久久久久不卡| 欧美视频在线一区二区三区| 外国成人直播| 伊人久久久久久久久久久久久久| 日韩精品乱码免费| 亚洲h片在线看| 亚洲影视综合| 国产视频一区欧美| 欧美日韩伦理片| 香蕉视频网站在线观看| 少妇献身老头系列| 久久久久久三级| 777影院狠狠色| 天天干天天操天天做| 国产精品无码在线播放| 国产精品传媒入口麻豆| 国产精品流白浆在线观看| 国产精品伦一区二区三区级视频频| 日韩免费电影在线观看| 狠狠综合久久av一区二区蜜桃| jizzjizzjizzjizz日本老师| 亚洲精品在线三区| 伦理在线一区| 女同毛片一区二区三区| 不卡在线视频中文字幕| 亚洲三级在线看| 极品人妻一区二区| 国产欧美一区二区白浆黑人| 91好色先生tv| 亚洲一级一区| 国产亚洲精品一区二区在线观看| 台湾成人av| 99热这里只有精品8| 久热精品免费视频| 欧美va天堂va视频va在线| 亚洲成人天堂网| 97dyy97影院理论片在线| 成人毛片18女人毛片| 99久久婷婷国产精品综合| 欧美日韩精品在线观看| 国产精品成人免费精品自在线观看| 青青青手机在线视频| 99re视频精品| 91精品国产沙发| 超碰最新在线| 免费成人在线视频观看| 久久电影一区二区| 国产一级片免费在线观看| 成人高清av在线| 国产盗摄一区二区三区| 亚洲аv电影天堂网| 国产香蕉在线视频| 国产欧美精品aaaaaa片| www.国产成人| 97超级碰在线看视频免费在线看| 色综合久久久无码中文字幕波多| 欧美色图一区| 亚洲精品在线91| 国产经典一区二区三区| 99久久精品国产一区二区小说| 日韩欧美大片| 国产亚洲欧美在线视频| 国产欧美综合色| 精品欧美一区二区在线观看视频| 青娱乐国产视频| 欧美成年黄网站色视频| 九九久久久久99精品| 色综合99久久久无码国产精品| 娇小11一12╳yⅹ╳毛片| 日本一级黄色大片| 91久久久亚洲精品| 国产精品91久久久| 在线成人激情黄色| 国产精品二区二区三区| 亚洲自拍偷拍区| 三级精品视频久久久久| 第四色在线视频| 国产黄a三级三级看三级| 无码中文字幕色专区| 精品久久久久久久久久久久包黑料| 亚洲精品天堂在线| 欧美一级片网址| 亚洲一区精品视频| 天天躁夜夜躁狠狠是什么心态| 欧洲色大大久久| 成人亚洲免费| 久久精品99久久久香蕉| 欧美伦理视频网站| 国产精品拍天天在线| 中文字幕激情视频| 7777精品久久久大香线蕉| 99热最新在线| 国产精品老牛影院在线观看| 人人干人人干人人| 制服.丝袜.亚洲.中文.综合懂色| 亚洲搞黄视频| 自拍日韩亚洲一区在线| 亚洲高清中文字幕| 先锋影音男人| 亚洲男人天堂av在线| 亚洲av成人片无码| 91在线视频导航| 一区两区小视频| 香蕉国产在线视频| 欧美freesex8一10精品| www.桃色.com| 国产美女主播在线| 亚洲精品中文综合第一页| 精品肉丝脚一区二区三区| 欧美成人乱码一二三四区免费| 天堂社区 天堂综合网 天堂资源最新版| 91久久精品美女高潮| 国产精品丝袜一区二区三区| 国产1卡2卡三卡四卡网站| 97精品人妻一区二区三区在线| 女人一区二区三区| 国产精品视频自拍| 天天草天天爽| 久久久久久中文字幕| 99在线观看精品视频| 亚洲免费成人在线视频| 韩国19禁主播vip福利视频| 国产成人精品免高潮在线观看| 手机看片福利盒子久久| 69av视频在线| 精品精品国产毛片在线看| 2022亚洲天堂| 免费看特级毛片| 青草成人免费视频| 精品动漫一区二区三区| 亚洲影视九九影院在线观看| 国产综合精品一区| 国产美女永久免费无遮挡| 亚洲美女性生活| 日韩欧美国产一区二区在线播放| 久久久久久久一区二区三区| 成人免费黄色| 成人毛片视频网站| 国产69精品久久久久毛片| 亚洲色图 在线视频| 亚洲精品色午夜无码专区日韩| 久久综合九色欧美狠狠| 精品免费久久久久久久| 91丨九色丨蝌蚪丨对白| wwwxx在线观看| 黄一区二区三区| 国产午夜精品一区二区理论影院| 99久久夜色精品国产亚洲狼| 久久久久久艹| 亚洲18私人小影院| 亚洲欧美卡通另类91av| 亚洲欧洲综合| 一区二区欧美亚洲| 亚洲乱码国产一区三区| 国产一区二区伦理| 色婷婷久久综合中文久久蜜桃av| 成人在线免费观看视频| 成人久久18免费网站图片| 88xx成人免费观看视频库| 欧美在线观看不卡| 亚洲免费观看高清完整版在线| 欧日韩精品视频| 青青一区二区三区| 一本色道久久综合狠狠躁的番外| 欧美电影免费观看高清| av综合网站| 97av在线视频免费播放| 日本视频免费观看| 涩涩av在线| 色婷婷综合成人| 乱小说综合网站| 99精品视频免费在线观看| 最新精品视频在线| 天天综合网在线| 欧美新色视频| aiss精品大尺度系列| 亚洲人成在线网站| 蜜桃av导航| 成人国产亚洲精品a区天堂华泰| 亚洲国产精品va| 九九在线精品| 欧美精品成人久久| 成人激情综合网站| 一区在线不卡| 手机在线观看av网站| 久久国产精品影视| 亚洲区一区二区三| 日韩av电影免费观看高清| 能在线观看的av网站| 三级在线观看视频| 99国产牛牛视频在线网站| 久久av资源| 国产精品日韩在线一区| 精品一区二区免费看| 国产三区四区在线观看| 欧美日韩三级一区| 国产无套粉嫩白浆内谢| 国产三级av在线| 黄色小视频免费在线观看| 国产欧亚日韩视频| 粉嫩的18在线观看极品精品| 小说区图片区色综合区| 又色又爽又高潮免费视频国产| 国产特黄大片aaaa毛片| 色哟哟精品视频| 青草在线视频在线观看| 丁香5月婷婷久久| 免费在线中文字幕| 欧洲精品久久一区二区| 中文字幕av日韩| 国内精品美女在线观看| 北条麻妃国产九九精品视频| 久久精品99久久| www欧美成人18+| 日韩在线一二三区| 欧美777四色影视在线| 国产成人久久久精品一区| 亚洲国产精品区| 亚洲一区免费| 91精品观看| 99久久99九九99九九九| 久久精品国产99久久| 肉色欧美久久久久久久免费看| 97精品国产97久久久久久春色| 午夜国产福利在线观看| 国产欧美一区二区三区久久| 人人干人人爱人人爱| 亚洲国产精品无码久久| 亚洲福利视频一区二区| 午夜精品久久久久久久99| 国产综合av一区二区三区| 国产一区 二区 三区一级| 日韩欧美一区二区三区| 婷婷五月色综合香五月| 欧美成人综合网站| 美女的尿口免费视频| 久久久久久久97| 成人a'v在线播放| 日韩精品中文字幕一区二区| 国产精品自拍小视频| 久久久999| 91国产视频在线观看| 制服丝袜综合日韩欧美| 曰韩不卡视频| 另类av导航| 亚洲蜜臀av乱码久久精品蜜桃| 欧美性xxxx18| 亚洲日本理论电影| 亚洲国产日韩欧美| 色一情一乱一伦一区二区三欧美| 国产精品视频自在线| 亚洲欧洲在线观看av| 超碰国产在线| 青青草超碰在线| 欧美96一区二区免费视频| 国产香蕉精品视频| 含羞草www国产在线视频| 欧美三日本三级少妇99| 韩国日本一区| 在线欧美视频| 欧美成人bangbros| 亚洲大胆人体在线| 色aⅴ色av色av偷拍| 日本一级黄色录像| 亚洲香蕉网站| 加勒比中文字幕精品| 新天天拍日日拍狠狠拍| 亚洲欧美视频一区| 久久久www免费人成黑人精品| 999热视频在线观看| 日韩.欧美.亚洲| 超碰免费在线播放| 欧美老女人性生活视频| 在线日韩一区二区| www.四虎在线| 国产全是老熟女太爽了| 色网站在线看| 久久久精品黄色| 欧美午夜www高清视频| 玩弄japan白嫩少妇hd| 国产专区中文字幕| 亚洲欧美国产另类| 午夜精品久久久久久久99热影院| 日本国产中文字幕| 欧美影视一区二区三区| 中文字幕久久久久| 97视频在线播放| 成人午夜淫片100集| 四虎海外影库www4hu| 久久99精品久久久水蜜桃| 亚洲看片网站| 乌克兰美女av| 国产精品久久久久久亚洲影视| 15—17女人毛片| 亚洲福利小视频| 熟女人妻在线视频| 亚洲男人天堂一区|