Docker: Difference between revisions
Jump to navigation
Jump to search
Line 18: | Line 18: | ||
winpty docker run -it --rm --name hello hello-world:latest | winpty docker run -it --rm --name hello hello-world:latest | ||
</source> | </source> | ||
==Networking== | |||
===Bridge=== | |||
<source lang="bash"> | |||
docker network create \ | |||
--driver bridge \ | |||
--gateway 10.20.13.1 \ | |||
--subnet 10.20.13.0/24 \ | |||
--ip-range 10.20.13.16/28 \ | |||
--opt com.docker.network.driver.mtu=1500 \ | |||
--opt com.docker.network.bridge.enable_icc=true \ | |||
--opt com.docker.network.bridge.default_bridge=false \ | |||
--opt com.docker.network.bridge.enable_ip_masquerade=true \ | |||
--opt com.docker.network.bridge.host_binding_ipv4=0.0.0.0 \ | |||
--opt com.docker.network.bridge.name=ckn.b01 ckn.b01 | |||
</source> | |||
<source lang="bash"> | |||
docker network create --subnet 10.20.13.32/28 ckn.b02 | |||
docker network create --subnet 10.20.13.48/28 ckn.b03 | |||
docker network create --subnet 10.20.13.64/28 ckn.b04 | |||
docker network create --subnet 10.20.13.80/28 ckn.b05 | |||
</source> | |||
===MAC VLAN=== | |||
<source lang="bash"> | |||
docker network create --subnet 10.19.83.0/24 --ip-range 10.19.83.16/28 ckn.v01 | |||
docker network create --subnet 10.19.83.0/24 --ip-range 10.19.83.32/28 ckn.v02 | |||
docker network create --subnet 10.19.83.0/24 --ip-range 10.19.83.48/28 ckn.v03 | |||
docker network create --subnet 10.19.83.0/24 --ip-range 10.19.83.64/28 ckn.v04 | |||
docker network create --subnet 10.19.83.0/24 --ip-range 10.19.83.80/28 ckn.v05 | |||
</source> | |||
===IP VLAN=== | |||
==Knowledge== | ==Knowledge== | ||
Line 57: | Line 90: | ||
docker network disconnect ckn.b00 nginx | docker network disconnect ckn.b00 nginx | ||
docker network connect --alias db --alias mysql ckn.b00 mysql | docker network connect --alias db --alias mysql ckn.b00 mysql | ||
</source> | </source> | ||
Revision as of 23:29, 14 September 2020
Windows 10 Home
# powershell
dism.exe /online /enable-feature /featurename:Microsoft-Windows-Subsystem-Linux /all /norestart
dism.exe /online /enable-feature /featurename:VirtualMachinePlatform /all /norestart
wsl --set-default-version 2
# powershell
docker pull hello-world
docker run -it --rm --name hello hello-world:latest
# gitbash
winpty docker pull hello-world
winpty docker run -it --rm --name hello hello-world:latest
Networking
Bridge
docker network create \
--driver bridge \
--gateway 10.20.13.1 \
--subnet 10.20.13.0/24 \
--ip-range 10.20.13.16/28 \
--opt com.docker.network.driver.mtu=1500 \
--opt com.docker.network.bridge.enable_icc=true \
--opt com.docker.network.bridge.default_bridge=false \
--opt com.docker.network.bridge.enable_ip_masquerade=true \
--opt com.docker.network.bridge.host_binding_ipv4=0.0.0.0 \
--opt com.docker.network.bridge.name=ckn.b01 ckn.b01
docker network create --subnet 10.20.13.32/28 ckn.b02
docker network create --subnet 10.20.13.48/28 ckn.b03
docker network create --subnet 10.20.13.64/28 ckn.b04
docker network create --subnet 10.20.13.80/28 ckn.b05
MAC VLAN
docker network create --subnet 10.19.83.0/24 --ip-range 10.19.83.16/28 ckn.v01
docker network create --subnet 10.19.83.0/24 --ip-range 10.19.83.32/28 ckn.v02
docker network create --subnet 10.19.83.0/24 --ip-range 10.19.83.48/28 ckn.v03
docker network create --subnet 10.19.83.0/24 --ip-range 10.19.83.64/28 ckn.v04
docker network create --subnet 10.19.83.0/24 --ip-range 10.19.83.80/28 ckn.v05
IP VLAN
Knowledge
docker network ls
docker network prune
docker network rm ckn.b00 ckn.b01
docker inspect nginx|grep "IPAddress"
docker network inspect bridge|grep "Gateway"
docker run --rm -dit --network \
none --name alpine alpine:latest ash;\
docker exec -it alpine ip link show
docker network create --driver bridge \
--opt com.docker.network.bridge.name=ckn.b00 ckn.b00
docker run --rm --detach \
--publish 1983:80 \
--name nginx \
nginx:1.19.2
docker network connect ckn.b00 nginx
docker inspect nginx|grep "IPAddress"
docker network disconnect bridge nginx
docker network disconnect ckn.b00 nginx
docker run -itd --network=ckn.b00 nginx
docker network disconnect ckn.b00 nginx
docker network connect --alias db --alias mysql ckn.b00 mysql