一、内核网络名称空间

  1、可通过ip netns进行操作

  1. [root@localhost /]# ip netns help
  2. Usage: ip netns list
  3. ip netns add NAME
  4. ip netns set NAME NETNSID
  5. ip [-all] netns delete [NAME]
  6. ip netns identify [PID]
  7. ip netns pids NAME
  8. ip [-all] netns exec [NAME] cmd ...
  9. ip netns monitor
  10. ip netns list-id

  2、启动各种网络类型的容器

    a、启动一个网络类型为bridge的容器并且在退出后自动删除(即能够对外通信的容器)。

  1. [root@localhost ~]# docker run --name t1 -it --network bridge --rm busybox:latest
  2. / # ifconfig
  3. eth0 Link encap:Ethernet HWaddr ::AC:::
  4. inet addr:172.17.0.4 Bcast:172.17.255.255 Mask:255.255.0.0
  5. UP BROADCAST RUNNING MULTICAST MTU: Metric:
  6. RX packets: errors: dropped: overruns: frame:
  7. TX packets: errors: dropped: overruns: carrier:
  8. collisions: txqueuelen:
  9. RX bytes: (508.0 B) TX bytes: (0.0 B)
  10.  
  11. lo Link encap:Local Loopback
  12. inet addr:127.0.0.1 Mask:255.0.0.0
  13. UP LOOPBACK RUNNING MTU: Metric:
  14. RX packets: errors: dropped: overruns: frame:
  15. TX packets: errors: dropped: overruns: carrier:
  16. collisions: txqueuelen:
  17. RX bytes: (0.0 B) TX bytes: (0.0 B)

    b、启动一个网络类型为none的容器并且在退出后自动删除(即封闭式容器)

  1. [root@localhost ~]# docker run --name t1 -it --network none --rm busybox:latest
  2. / # ifconfig
  3. lo Link encap:Local Loopback
  4. inet addr:127.0.0.1 Mask:255.0.0.0
  5. UP LOOPBACK RUNNING MTU: Metric:
  6. RX packets: errors: dropped: overruns: frame:
  7. TX packets: errors: dropped: overruns: carrier:
  8. collisions: txqueuelen:
  9. RX bytes: (0.0 B) TX bytes: (0.0 B)
  10.  
  11. / # exit

    c、容器默认的主机名就是其id,也可以在启动的时候给上主机名

  1. [root@localhost ~]# docker run --name t1 -it --network bridge -h wohaoshuai --rm busybox:latest
  2. / # hostname
  3. wohaoshuai

    d、容器默认的dns是宿主机的dns,可以在启动的时候给上其dns

  1. [root@localhost ~]# docker run --name t1 -it --network bridge -h wohaoshuai --dns 114.114.114.114 --rm busybox:latest
  2. / # cat /etc/hosts
  3. 127.0.0.1 localhost
  4. :: localhost ip6-localhost ip6-loopback
  5. fe00:: ip6-localnet
  6. ff00:: ip6-mcastprefix
  7. ff02:: ip6-allnodes
  8. ff02:: ip6-allrouters
  9. 172.17.0.4 wohaoshuai
  10. / # cat /etc/resolv.conf
  11. nameserver 114.114.114.114

    e、可以给主机添加主机解析记录

  1. [root@localhost ~]# docker run --name t1 -it --network bridge -h wohaoshuai --dns 114.114.114.114 --add-host www.wohaoshuai.com:192.168.11.11 --rm busybox:latest
  2. / # cat /etc/hosts
  3. 127.0.0.1 localhost
  4. :: localhost ip6-localhost ip6-loopback
  5. fe00:: ip6-localnet
  6. ff00:: ip6-mcastprefix
  7. ff02:: ip6-allnodes
  8. ff02:: ip6-allrouters
  9. 192.168.11.11 www.wohaoshuai.com
  10. 172.17.0.4 wohaoshuai

  3、端口映射 -p

   

    a、将指定的容器端口映射至主机所有地址的一个动态端口

  1. [root@localhost ~]# docker run -it -p --rm --name webtest1 httpd
  2. AH00558: httpd: Could not reliably determine the server's fully qualified domain name, using 172.17.0.4. Set the 'ServerName' directive globally to suppress this message
  3. AH00558: httpd: Could not reliably determine the server's fully qualified domain name, using 172.17.0.4. Set the 'ServerName' directive globally to suppress this message
  4. [Sat Apr ::16.001251 ] [mpm_event:notice] [pid :tid ] AH00489: Apache/2.4. (Unix) configured -- resuming normal operations
  5. [Sat Apr ::16.001475 ] [core:notice] [pid :tid ] AH00094: Command line: 'httpd -D FOREGROUND'
  6. 192.168.10.1 - - [/Apr/::: +] "GET / HTTP/1.1"
  7. 192.168.10.1 - - [/Apr/::: +] "GET /favicon.ico HTTP/1.1"

  8. 另开一个shell查看:
  9. [root@localhost ~]# docker port webtest1
  10. /tcp -> 0.0.0.0:

    b、将容器端口映射至指定的主机端口

  1. [root@localhost ~]# docker run -it --rm -p : --name webtest1 httpd
  2. AH00558: httpd: Could not reliably determine the server's fully qualified domain name, using 172.17.0.4. Set the 'ServerName' directive globally to suppress this message
  3. AH00558: httpd: Could not reliably determine the server's fully qualified domain name, using 172.17.0.4. Set the 'ServerName' directive globally to suppress this message
  4. [Sat Apr ::43.973155 ] [mpm_event:notice] [pid :tid ] AH00489: Apache/2.4. (Unix) configured -- resuming normal operations
  5. [Sat Apr ::43.973377 ] [core:notice] [pid :tid ] AH00094: Command line: 'httpd -D FOREGROUND'
  6.  
  7. 另起一个shell查看:
  8. [root@localhost ~]# docker port webtest1
  9. /tcp -> 0.0.0.0:

    c、将指定的容器端口映射至主机指定ip的动态端口

  1. [root@localhost ~]# docker run -it --rm -p 192.168.10.46:: --name webtest1 httpd
  2. AH00558: httpd: Could not reliably determine the server's fully qualified domain name, using 172.17.0.4. Set the 'ServerName' directive globally to suppress this message
  3. AH00558: httpd: Could not reliably determine the server's fully qualified domain name, using 172.17.0.4. Set the 'ServerName' directive globally to suppress this message
  4. [Sat Apr ::08.815379 ] [mpm_event:notice] [pid :tid ] AH00489: Apache/2.4. (Unix) configured -- resuming normal operations
  5. [Sat Apr ::08.815558 ] [core:notice] [pid :tid ] AH00094: Command line: 'httpd -D FOREGROUND'
  6.  
  7. 另开一个shell查看:
  8. [root@localhost ~]# docker port webtest1
  9. /tcp -> 192.168.10.46:

    d、将指定的容器端口映射至主机指定的ip 的端口

  1. [root@localhost ~]# docker run -it --rm -p 192.168.10.46:: --name webtest1 httpd
  2. AH00558: httpd: Could not reliably determine the server's fully qualified domain name, using 172.17.0.4. Set the 'ServerName' directive globally to suppress this message
  3. AH00558: httpd: Could not reliably determine the server's fully qualified domain name, using 172.17.0.4. Set the 'ServerName' directive globally to suppress this message
  4. [Sat Apr ::47.699843 ] [mpm_event:notice] [pid :tid ] AH00489: Apache/2.4. (Unix) configured -- resuming normal operations
  5. [Sat Apr ::47.699977 ] [core:notice] [pid :tid ] AH00094: Command line: 'httpd -D FOREGROUND'
  6. 192.168.10.1 - - [/Apr/::: +] "GET / HTTP/1.1"
  7. 192.168.10.1 - - [/Apr/::: +] "GET /favicon.ico HTTP/1.1"
  8.  
  9. [root@localhost ~]# docker port webtest1
  10. /tcp -> 192.168.10.46:

  4、暴露容器所有端口到宿主机 -P

  5、启动联盟式容器

    a、启动容器1

  1. [root@localhost ~]# docker run -it --name b1 --rm busybox
  2. / # ifconfig
  3. eth0 Link encap:Ethernet HWaddr ::AC:::
  4. inet addr:172.17.0.4 Bcast:172.17.255.255 Mask:255.255.0.0
  5. UP BROADCAST RUNNING MULTICAST MTU: Metric:
  6. RX packets: errors: dropped: overruns: frame:
  7. TX packets: errors: dropped: overruns: carrier:
  8. collisions: txqueuelen:
  9. RX bytes: (578.0 B) TX bytes: (0.0 B)
  10.  
  11. lo Link encap:Local Loopback
  12. inet addr:127.0.0.1 Mask:255.0.0.0
  13. UP LOOPBACK RUNNING MTU: Metric:
  14. RX packets: errors: dropped: overruns: frame:
  15. TX packets: errors: dropped: overruns: carrier:
  16. collisions: txqueuelen:
  17. RX bytes: (0.0 B) TX bytes: (0.0 B)

    b、启动容器2共享容器1的网络名称空间(但是文件系统不是共享的)

  1. [root@localhost ~]# docker run -it --name b2 --network container:b1 --rm busybox
  2. / # ifconfig
  3. eth0 Link encap:Ethernet HWaddr ::AC:::
  4. inet addr:172.17.0.4 Bcast:172.17.255.255 Mask:255.255.0.0
  5. UP BROADCAST RUNNING MULTICAST MTU: Metric:
  6. RX packets: errors: dropped: overruns: frame:
  7. TX packets: errors: dropped: overruns: carrier:
  8. collisions: txqueuelen:
  9. RX bytes: (648.0 B) TX bytes: (0.0 B)
  10.  
  11. lo Link encap:Local Loopback
  12. inet addr:127.0.0.1 Mask:255.0.0.0
  13. UP LOOPBACK RUNNING MTU: Metric:
  14. RX packets: errors: dropped: overruns: frame:
  15. TX packets: errors: dropped: overruns: carrier:
  16. collisions: txqueuelen:
  17. RX bytes: (0.0 B) TX bytes: (0.0 B)

    c、在容器1上启动一个httpd服务

/ # mkdir /tmp/httptest
/ # echo "http test" >> /tmp/httptest/index.html
/ # httpd -h /tmp/httptest/
/ # netstat -anpt
Active Internet connections (servers and established)
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
tcp 0 0 :::80 :::* LISTEN 9/httpd
tcp 0 0 ::ffff:127.0.0.1:80 ::ffff:127.0.0.1:33282 TIME_WAIT -

    d、在容器2上查看

  1. / # wget -O - -q 127.0.0.1
  2. http test
  3. / # netstat -anpt
  4. Active Internet connections (servers and established)
  5. Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
  6. tcp ::: :::* LISTEN -

  6、共享主机网络空间

    a、启动容器2,共享主机网络空间

  1. [root@localhost ~]# docker run -it --name b2 --network host --rm busybox
  2. / # ifconfig
  3. docker0 Link encap:Ethernet HWaddr :::6B::
  4. inet addr:172.17.0.1 Bcast:172.17.255.255 Mask:255.255.0.0
  5. inet6 addr: fe80:::7ff:fe6b:/ Scope:Link
  6. UP BROADCAST RUNNING MULTICAST MTU: Metric:
  7. RX packets: errors: dropped: overruns: frame:
  8. TX packets: errors: dropped: overruns: carrier:
  9. collisions: txqueuelen:
  10. RX bytes: (2.9 KiB) TX bytes: (4.1 KiB)
  11.  
  12. ens33 Link encap:Ethernet HWaddr :0C::A7:CE:
  13. inet addr:192.168.10.46 Bcast:192.168.10.255 Mask:255.255.255.0
  14. inet6 addr: fe80::2b2a:bd85:8d15:14c/ Scope:Link
  15. UP BROADCAST RUNNING MULTICAST MTU: Metric:
  16. RX packets: errors: dropped: overruns: frame:
  17. TX packets: errors: dropped: overruns: carrier:
  18. collisions: txqueuelen:
  19. RX bytes: (51.6 MiB) TX bytes: (1.1 MiB)
  20.  
  21. lo Link encap:Local Loopback
  22. inet addr:127.0.0.1 Mask:255.0.0.0
  23. inet6 addr: ::/ Scope:Host
  24. UP LOOPBACK RUNNING MTU: Metric:
  25. RX packets: errors: dropped: overruns: frame:
  26. TX packets: errors: dropped: overruns: carrier:
  27. collisions: txqueuelen:
  28. RX bytes: (5.1 KiB) TX bytes: (5.1 KiB)
  29.  
  30. veth24abfad Link encap:Ethernet HWaddr ::2D:BA:ED:
  31. inet6 addr: fe80:::2dff:feba:ed63/ Scope:Link
  32. UP BROADCAST RUNNING MULTICAST MTU: Metric:
  33. RX packets: errors: dropped: overruns: frame:
  34. TX packets: errors: dropped: overruns: carrier:
  35. collisions: txqueuelen:
  36. RX bytes: (0.0 B) TX bytes: (1.5 KiB)
  37.  
  38. veth34dd4fe Link encap:Ethernet HWaddr EA:F1:6D:7E:EB:
  39. inet6 addr: fe80::e8f1:6dff:fe7e:eb23/ Scope:Link
  40. UP BROADCAST RUNNING MULTICAST MTU: Metric:
  41. RX packets: errors: dropped: overruns: frame:
  42. TX packets: errors: dropped: overruns: carrier:
  43. collisions: txqueuelen:
  44. RX bytes: (0.0 B) TX bytes: (648.0 B)
  45.  
  46. vetha7c5640 Link encap:Ethernet HWaddr CE:::9D:AE:0E
  47. inet6 addr: fe80::cc76:19ff:fe9d:ae0e/ Scope:Link
  48. UP BROADCAST RUNNING MULTICAST MTU: Metric:
  49. RX packets: errors: dropped: overruns: frame:
  50. TX packets: errors: dropped: overruns: carrier:
  51. collisions: txqueuelen:
  52. RX bytes: (0.0 B) TX bytes: (1.7 KiB)

    b、在容器中启动http服务,在宿主机中也可访问

  1. / # echo "hello wohaoshuai" > /tmp/index.html
  2. / # httpd -h /tmp/
  3. / #
  4. / #
  5. / #
  6. / # netstat -anpt
  7. Active Internet connections (servers and established)
  8. Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
  9. tcp 0.0.0.0: 0.0.0.0:* LISTEN -
  10. tcp 0.0.0.0: 0.0.0.0:* LISTEN -
  11. tcp 127.0.0.1: 0.0.0.0:* LISTEN -
  12. tcp 192.168.10.46: 192.168.10.1: ESTABLISHED -
  13. tcp 192.168.10.46: 192.168.10.1: ESTABLISHED -
  14. tcp ::: :::* LISTEN -
  15. tcp ::: :::* LISTEN /httpd
  16. tcp ::: :::* LISTEN -
  17. tcp ::: :::* LISTEN -

二、修改docker 默认项

  1、自定义docker网络属性

    

  1. [root@localhost ~]# more /etc/docker/daemon.json
  2. {
  3. "registry-mirrors": ["https://guxaj7v7.mirror.aliyuncs.com","https://registry.docker-cn.com"],
  4. "bip": "10.0.0.1/16"
  5. }
  6. [root@localhost ~]# ip addr
  7. : lo: <LOOPBACK,UP,LOWER_UP> mtu qdisc noqueue state UNKNOWN group default qlen
  8. link/loopback ::::: brd :::::
  9. inet 127.0.0.1/ scope host lo
  10. valid_lft forever preferred_lft forever
  11. inet6 ::/ scope host
  12. valid_lft forever preferred_lft forever
  13. : ens33: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu qdisc pfifo_fast state UP group default qlen
  14. link/ether :0c::a7:ce: brd ff:ff:ff:ff:ff:ff
  15. inet 192.168.10.46/ brd 192.168.10.255 scope global noprefixroute ens33
  16. valid_lft forever preferred_lft forever
  17. inet6 fe80::2b2a:bd85:8d15:14c/ scope link noprefixroute
  18. valid_lft forever preferred_lft forever
  19. : docker0: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu qdisc noqueue state DOWN group default
  20. link/ether :::6b:: brd ff:ff:ff:ff:ff:ff
  21. inet 10.0.0.1/ brd 10.0.255.255 scope global docker0
  22. valid_lft forever preferred_lft forever
  23. inet6 fe80:::7ff:fe6b:/ scope link
  24. valid_lft forever preferred_lft forever

  2、修改docker 监听方式

    a、方式1

    b、方式2:不同版本docker修改方式不一样,另一种修改方式如下:

      vim /usr/lib/systemd/system/docker.service

      在[service]下加如下参数

  1. [Service]
  2. ExecStart=
  3. ExecStart=/usr/bin/dockerd -H tcp://0.0.0.0:2375 -H unix://var/run/docker.sock

      重启docker 服务

  1. [root@localhost ~]# systemctl daemon-reload
  2. [root@localhost ~]# systemctl restart docker
  3. [root@localhost ~]# netstat -anpt
  4. Active Internet connections (servers and established)
  5. Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
  6. tcp 0.0.0.0: 0.0.0.0:* LISTEN /rpcbind
  7. tcp 0.0.0.0: 0.0.0.0:* LISTEN /sshd
  8. tcp 127.0.0.1: 0.0.0.0:* LISTEN /master
  9. tcp 192.168.10.46: 192.168.10.1: ESTABLISHED /sshd: root@pts
  10. tcp 192.168.10.46: 192.168.10.1: ESTABLISHED /sshd: root@pts
  11. tcp6 ::: :::* LISTEN /dockerd
  12. tcp6 ::: :::* LISTEN /rpcbind
  13. tcp6 ::: :::* LISTEN /sshd
  14. tcp6 ::: :::* LISTEN /master
  15. [root@localhost ~]# ls /var/run/
  16. abrt cron.reboot docker.sock lock mod_fcgid rpcbind.lock syslogd.pid utmp
  17. atd.pid dbus ebtables.lock log mount rpcbind.sock systemd vmware
  18. auditd.pid dmeventd-client faillock lsm netreport sepermit tmpfiles.d xtables.lock
  19. console dmeventd-server firewalld lvm NetworkManager setrans tuned
  20. containerd docker httpd lvmetad.pid plymouth sshd.pid udev
  21. crond.pid docker.pid initramfs mdadm rpcbind sudo user

    c、访问

  1. [root@localhost ~]# docker -H 192.168.10.46 ps
  2. CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
  3. [root@localhost ~]# docker -H 192.168.10.46 images
  4. REPOSITORY TAG IMAGE ID CREATED SIZE
  5. httpd latest d4a07e6ce470 days ago 132MB
  6. busybox latest af2f74c517aa days ago .2MB
  7. centos latest 9f38484d220f weeks ago 202MB

三、不同网络之间容器互相访问

  1、创建网络

  1. [root@localhost ~]# docker network create -d bridge --subnet "172.16.0.0/16" --gateway "172.16.0.1" mybr0
  2. fceba8db97014f8f762b48cced3399ecb539b4510f68181df992997d67ae1307
  3. [root@localhost ~]# docker network ls
  4. NETWORK ID NAME DRIVER SCOPE
  5. 0479ba9d5a7c bridge bridge local
  6. 1f98da302a92 host host local
  7. fceba8db9701 mybr0 bridge local
  8. bdb9eff6069c none null local
  9. [root@localhost ~]# ip addr
  10. : lo: <LOOPBACK,UP,LOWER_UP> mtu qdisc noqueue state UNKNOWN group default qlen
  11. link/loopback ::::: brd :::::
  12. inet 127.0.0.1/ scope host lo
  13. valid_lft forever preferred_lft forever
  14. inet6 ::/ scope host
  15. valid_lft forever preferred_lft forever
  16. : ens33: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu qdisc pfifo_fast state UP group default qlen
  17. link/ether :0c::a7:ce: brd ff:ff:ff:ff:ff:ff
  18. inet 192.168.10.46/ brd 192.168.10.255 scope global noprefixroute ens33
  19. valid_lft forever preferred_lft forever
  20. inet6 fe80::2b2a:bd85:8d15:14c/ scope link noprefixroute
  21. valid_lft forever preferred_lft forever
  22. : docker0: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu qdisc noqueue state DOWN group default
  23. link/ether :::6b:: brd ff:ff:ff:ff:ff:ff
  24. inet 10.0.0.1/ brd 10.0.255.255 scope global docker0
  25. valid_lft forever preferred_lft forever
  26. inet6 fe80:::7ff:fe6b:/ scope link
  27. valid_lft forever preferred_lft forever
  28. : br-fceba8db9701: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu qdisc noqueue state DOWN group default
  29. link/ether ::7d::e3:a0 brd ff:ff:ff:ff:ff:ff
  30. inet 172.16.0.1/ brd 172.16.255.255 scope global br-fceba8db9701
  31. valid_lft forever preferred_lft forever

  2、创建容器1并加入到刚刚创建的网络中

  1. [root@localhost ~]# docker run --name t1 -it --network mybr0 busybox:latest
  2. / # ifconfig
  3. eth0 Link encap:Ethernet HWaddr ::AC:::
  4. inet addr:172.16.0.2 Bcast:172.16.255.255 Mask:255.255.0.0
  5. UP BROADCAST RUNNING MULTICAST MTU: Metric:
  6. RX packets: errors: dropped: overruns: frame:
  7. TX packets: errors: dropped: overruns: carrier:
  8. collisions: txqueuelen:
  9. RX bytes: (1.2 KiB) TX bytes: (0.0 B)
  10.  
  11. lo Link encap:Local Loopback
  12. inet addr:127.0.0.1 Mask:255.0.0.0
  13. UP LOOPBACK RUNNING MTU: Metric:
  14. RX packets: errors: dropped: overruns: frame:
  15. TX packets: errors: dropped: overruns: carrier:
  16. collisions: txqueuelen:
  17. RX bytes: (0.0 B) TX bytes: (0.0 B)

  3、创建容器2并加入bridge网络

  1. [root@localhost ~]# docker run --name t2 -it --network bridge busybox:latest
  2. / # ifconfig
  3. eth0 Link encap:Ethernet HWaddr ::0A:::
  4. inet addr:10.0.0.2 Bcast:10.0.255.255 Mask:255.255.0.0
  5. UP BROADCAST RUNNING MULTICAST MTU: Metric:
  6. RX packets: errors: dropped: overruns: frame:
  7. TX packets: errors: dropped: overruns: carrier:
  8. collisions: txqueuelen:
  9. RX bytes: (508.0 B) TX bytes: (0.0 B)
  10.  
  11. lo Link encap:Local Loopback
  12. inet addr:127.0.0.1 Mask:255.0.0.0
  13. UP LOOPBACK RUNNING MTU: Metric:
  14. RX packets: errors: dropped: overruns: frame:
  15. TX packets: errors: dropped: overruns: carrier:
  16. collisions: txqueuelen:
  17. RX bytes: (0.0 B) TX bytes: (0.0 B)

  4、要想容器1能够访问到容器2则需要在宿主机上开启nat转发

    a、查看是否开启转发

  1. [root@localhost ~]# cat /proc/sys/net/ipv4/ip_forward

    b、在iptables上将相应规则打开即可,因为iptables默认是阻止两个不同网络容器之间进行通信的。

Docker 学习5 Docker容器网络的更多相关文章

  1. Docker学习(六): 网络使用与配置

    特别声明: 博文主要是学习过程中的知识整理,以便之后的查阅回顾.部分内容来源于网络(如有摘录未标注请指出).内容如有差错,也欢迎指正! =============系列文章============= 1 ...

  2. Docker学习之Docker容器基本使用

    Docker学习之Docker容器基本使用 新建容器并启动 命令格式:docker run --options repository:tag 后台运行 命令格式:-d 已存在的容器相关操作 启动:do ...

  3. Docker学习之Docker镜像基本使用

    Docker学习之Docker镜像基本使用 获取镜像 命令格式:docker pull [选项] [Docker Registry 地址[:端口号]/]仓库名[:标签] 例如: docker pull ...

  4. Docker学习笔记 — Docker私有仓库搭建

    Docker学习笔记 — Docker私有仓库搭建   目录(?)[-] 环境准备 搭建私有仓库 测试 管理仓库中的镜像 查询 删除 Registry V2   和Mavan的管理一样,Dockers ...

  5. Docker的单主机容器网络

    作者:杨冬 欢迎转载,也请保留这段声明.谢谢! 出处: https://andyyoung01.github.io/ 或 http://andyyoung01.16mb.com/ 本篇文章主要探索Do ...

  6. Docker学习笔记 - Docker容器内部署redis

    Docker学习笔记(2-4)Docker应用实验-redist server 和client的安装使用 一.获取redis容器(含客户端和服务端) 二.创建服务端容器 1.在终端A中运行redis- ...

  7. Docker学习笔记 - Docker容器之间的连接

    学习目标: 容器之间可以相互连接访问:: --link redis:redisAlias 准备工作 FROM ubuntu:14.04 RUN apt-get install -y ping RUN  ...

  8. Docker学习笔记——制作容器与容器概念

    Docker能做些什么? 1.docker能够解决虚拟机能够解决的问题 2.隔离应用依赖 3.创建应用镜像并复制 4.创建容易分发的即启即用的应用 5.docker的想法是创建软件程序可移植的轻量容器 ...

  9. <Docker学习>6. docker使用网络

    在容器中部署一个web应用,外部如何访问? 容器与容器间如何访问? 外部访问容器 容器可以运行一些网络应用,让外部也可以访问的话,需要进行服务器和容器的端口映射 -p 或者 -P -P默认会分配一个4 ...

  10. DOCKER学习_004:Docker网络

    一 简介 当Docker进程启动时,会在主机上创建一个名为docker0的虚拟网桥,此主机上启动的docker容器会连接到这个虚拟网桥上.虚拟网桥的工作方式和物理交换机类似,这样主机上的所有容器就通过 ...

随机推荐

  1. Java基础 -- 深入理解Java类型信息(Class对象)与反射机制

    一 RTTI概念 认识Claa对象之前,先来了解一个概念,RTTI(Run-Time Type Identification)运行时类型识别,对于这个词一直是 C++ 中的概念,至于Java中出现RT ...

  2. 四、Tensorflow的分布式训练

    TensorFlow中的集群(cluster)指的是一系列能够针对图(Graph)进行分布式计算任务(task).每个任务是同服务(server)相关联的.TensorFlow中的服务会包含一个用于创 ...

  3. vue路由实现多视图的单页应用

    多视图的单页应用:在一个页面中实现多个页面不同切换,url也发生相应变化. router-view结合this.$router.push("/pickUp")实现,效果如下: 当点 ...

  4. STM32的内存管理

    ref:https://www.cnblogs.com/leo0621/p/9977932.html 这里针对STM32F407芯片+1M外部内存的内存管理!(全篇是个人愚见,如果错误,请不吝指出!) ...

  5. Maven之阿里云镜像仓库配置

    方式一:全局配置:修改maven的setting.xml配置 在mirrors节点下面添加子节点: <mirror> <id>nexus-aliyun</id> & ...

  6. Python高级笔记(二) -- 深拷贝和浅拷贝

    1. 深拷贝 1.1 类型1 注意: d没有改变, 因为d所拷贝的数据没有改变, 而是c往后添加数据. 1.2 类型2: 元组 如果copy.copy拷贝的是元组是深拷贝! 不会进行浅拷贝, 仅仅是指 ...

  7. 深入理解Java自带的线程池和缓冲队列

    前言 线程池是什么 线程池的概念是初始化线程池时在池中创建空闲的线程,一但有工作任务,可直接使用线程池中的线程进行执行工作任务,任务执行完成后又返回线程池中成为空闲线程.使用线程池可以减少线程的创建和 ...

  8. H5_0004:JS设置循环debugger的方法

    在HTML页面加上如下代码,则PC打开控制台后,就会循环debugger,防止调试代码. <script>eval(function (p, a, c, k, e, r) { e = fu ...

  9. jmeter和loadrunner关于分布式部署测试计划的优缺点

    1.都可以实现分布式负载,相对来说loadrunner更强大一些 2.都支持在windows和linux环境的负载生成器,控制台方面,jmeter跨平台,而loadrunner不是 3.loadrun ...

  10. 查看提交历史(git log)

    git log 命令 在完成了几次提交,或者克隆了一个已有提交历史的仓库后,要查看历史提交记录,可以通过git log命令来实现. $ git log commit 0becea8e1966df258 ...