給Docker容器建立固定的ip

2021-09-27 09:03:50 字數 491 閱讀 2589

解釋: 一般在分布式系統中 當a伺服器 不需要和b伺服器通訊的時候 我們指定對應的

網段 只能同乙個局域下可以訪問

1.1 建立網路 指定網段

docker network create --subnet=172.18.0.0/16 mynet

1.2 建立容器 指定容器的ip

docker run -it -d --net mynet --ip 172.18.0.8 --name mytomcat tomcat

1.3 刪除指定網段 

1.3.1 安裝橋接工具 yum install bridge-utils

1.3.2 使用brctl show檢視網橋

******************************===

1.3.3 ifconfig virbr0 down 

1.3.4 brctl delbr virbr0 刪除網段

docker固定IP容器構造

基於centos7安裝docker不需要使用amaza的repo,直接就可使用shell命令 1.安裝docker yum install docker io y ps 在centos6.5上可能會出現這樣的錯誤 warn 0000 you are running linux kernel vers...

Docker容器固定IP分配

我們在使用docker run 建立docker 容器時,可以用 net 選項指定容器的網路模式,docker 有以下4 種網路模式 host模式,使用 net host 指定。container模式,使用 net container name or id 指定。none模式,使用 net none...

Docker容器固定IP分配

我們在使用docker run 建立docker 容器時,可以用 net 選項指定容器的網路模式,docker 有以下4 種網路模式 host模式,使用 net host 指定。container模式,使用 net container name or id 指定。none模式,使用 net none...