完整修复宿主机重启后 docker 自定义网络丢失 并重新恢复容器

cat fix-network.md

1. after hw reboot not lose docker custome network

  • avoid after hw restart customer’s docker network
    vim /etc/sysconfig/docker
    DISABLE_CRASH_FILES_DELETE=true
[root@16-0-0-85 ganglia]# cat /etc/sysconfig/docker
# /etc/sysconfig/docker

# Modify these options if you want to change the way the docker daemon runs
OPTIONS='--live-restore'

# avoid after hw restart customer's docker network
DISABLE_CRASH_FILES_DELETE=true

DOCKER_CERT_PATH=/etc/docker

2. recreate original docker custome network

  • before
[root@16-0-0-85 ganglia]# docker network ls
NETWORK ID          NAME                DRIVER              SCOPE
1780737f539b        bridge              bridge              local
1b0645efa151        host                host                local
d7bdc7f15291        none                null                local
[root@16-0-0-85 ganglia]#
  • recreate
[root@16-0-0-85 ganglia]# docker network create --subnet 172.18.0.0/16 mybridge2
c7d78111dc1b0d857c75195e66620c764f6a67d02ee5e2d50acf7946d17c5446
[root@16-0-0-85 ganglia]#
[root@16-0-0-85 ganglia]# docker network create --subnet 172.19.0.0/16 mybridge
89f8372b190c0570987d31fee7500525c0ab0711be9822d3a1de98eac25fc4ee
[root@16-0-0-85 ganglia]#
  • after
[root@16-0-0-85 ganglia]# docker network ls
NETWORK ID          NAME                DRIVER              SCOPE
1780737f539b        bridge              bridge              local
1b0645efa151        host                host                local
89f8372b190c        mybridge            bridge              local
c7d78111dc1b        mybridge2           bridge              local
d7bdc7f15291        none                null                local
[root@16-0-0-85 ganglia]#

3. reconnect containers

[root@16-0-0-85 ganglia]# docker network connect mybridge ganglia-s-gmond-11
[root@16-0-0-85 ganglia]# docker network connect mybridge ganglia-s-gmond-12
[root@16-0-0-85 ganglia]#
[root@16-0-0-85 ganglia]# docker network connect mybridge2 ganglia-s-gmond-21
[root@16-0-0-85 ganglia]# docker network connect mybridge2 ganglia-s-gmond-22
[root@16-0-0-85 ganglia]#

4. restart bad containers

[root@16-0-0-85 ganglia]# docker start ganglia-s-gmond-11
ganglia-s-gmond-11
[root@16-0-0-85 ganglia]# docker start ganglia-s-gmond-12
ganglia-s-gmond-12
[root@16-0-0-85 ganglia]# docker start ganglia-s-gmond-21
ganglia-s-gmond-21
[root@16-0-0-85 ganglia]# docker start ganglia-s-gmond-22
ganglia-s-gmond-22
[root@16-0-0-85 ganglia]#

我们下期见,拜拜!

你可能感兴趣的:(Linux,docker,网络,openEuler)