測驗環境:
Windows Server 2019資料中心版本
步驟一:
1. 獲取當前所有的網卡
PS C:\> Get-NetAdapter
結果:
回傳所有的網卡資訊,選擇你需要開發的網卡名稱,注意這里的網卡不能是虛擬網卡,應該是未進行虛擬化的物理網卡,
2.創建Docker的透明網路驅動
docker network create -d "transparent" --subnet 192.168.0.0/24 --gateway 192.168.0.1 -o com.docker.network.windowsshim.dnsservers="192.168.0.254" -o com.docker.network.windowsshim.interface="NIC2" my_transparent
意思就是通過NIC2創建一個透明網路,可進行物理交換機的訪問,其中DNS的地址為192.168.0.254,網關地址為192.168.0.1,子網掩碼:255.255.255.0
3.指定改網路運行容器
docker run -v c:\app:c:\app -it -d --ip=192.168.0.92 --net=my_transparent --name=ibms ibms:v1.50
指定容器運行的IP地址為192.168.0.92,如果你需要動態分配IP就不指定ip引數,
4.查看運行結果
docker exec -it ibms cmd
然后運行命令:
ipconfig /all
獲得結果:
Windows IP Configuration
Host Name . . . . . . . . . . . . : bb304d962c2d
Primary Dns Suffix . . . . . . . :
Node Type . . . . . . . . . . . . : Hybrid
IP Routing Enabled. . . . . . . . : No
WINS Proxy Enabled. . . . . . . . : No
Ethernet adapter vEthernet (Ethernet):
Connection-specific DNS Suffix . :
Description . . . . . . . . . . . : Hyper-V Virtual Ethernet Adapter #4
Physical Address. . . . . . . . . : 00-15-5D-AF-F2-5A
DHCP Enabled. . . . . . . . . . . : No
Autoconfiguration Enabled . . . . : Yes
Link-local IPv6 Address . . . . . : fe80::2904:8bb9:e118:70a7%46(Preferred)
IPv4 Address. . . . . . . . . . . : 192.168.0.92(Preferred)
Subnet Mask . . . . . . . . . . . : 255.255.255.0
Default Gateway . . . . . . . . . : 192.168.0.1
DNS Servers . . . . . . . . . . . : 192.168.0.254
NetBIOS over Tcpip. . . . . . . . : Disabled
驗證正確!
轉載請註明出處,本文鏈接:https://www.uj5u.com/caozuo/388894.html
上一篇:Linux三劍客命令—sed