Linux/Docker/Networking: Difference between revisions
mNo edit summary |
mNo edit summary |
||
(2 intermediate revisions by the same user not shown) | |||
Line 13: | Line 13: | ||
* add custom route to docker container | * add custom route to docker container | ||
<pre><nowiki> | |||
<pre> | |||
<nowiki> | |||
docker exec --privileged munin ip route add 192.168.111.0/24 via 172.1.50.127 | docker exec --privileged munin ip route add 192.168.111.0/24 via 172.1.50.127 | ||
nsenter -n -t $(docker inspect --format {{.State.Pid}} webproxy) ip route add 192.168.111.0/24 via 172.1.50.127 | nsenter -n -t $(docker inspect --format {{.State.Pid}} webproxy) ip route add 192.168.111.0/24 via 172.1.50.127 | ||
Line 24: | Line 22: | ||
nsenter -n -t $(docker inspect --format {{.State.Pid}} munin) ip route show | nsenter -n -t $(docker inspect --format {{.State.Pid}} munin) ip route show | ||
nsenter -n -t $(docker inspect --format {{.State.Pid}} munin) ping 192.168.111.11 | nsenter -n -t $(docker inspect --format {{.State.Pid}} munin) ping 192.168.111.11 | ||
</nowiki> | |||
<pre> | ip route show | ||
</nowiki></pre> | |||
[[Category:Linux/Docker]] | [[Category:Linux/Docker]] | ||
[[Category:Linux]] | [[Category:Linux]] |
Latest revision as of 17:10, 19 November 2023
- List docker container with IPs
docker ps -q | xargs -n 1 docker inspect --format '{{range .NetworkSettings.Networks}}{{.IPAddress}} {{end}} {{ .Name }}' | sed 's/ \// /'
- Create docker network
docker network create wireguard docker network create --subnet 172.1.50.0/24 wireguard docker network create --subnet 172.1.50.0/24 --ip-range=172.1.50.0/25 wireguard docker network inspect wireguard
- add custom route to docker container
docker exec --privileged munin ip route add 192.168.111.0/24 via 172.1.50.127 nsenter -n -t $(docker inspect --format {{.State.Pid}} webproxy) ip route add 192.168.111.0/24 via 172.1.50.127 nsenter -n -t $(docker inspect --format {{.State.Pid}} webproxy) ip route show nsenter -n -t $(docker inspect --format {{.State.Pid}} webproxy) ping 192.168.111.11 nsenter -n -t $(docker inspect --format {{.State.Pid}} munin) ip route add 192.168.111.0/24 via 172.1.50.127 nsenter -n -t $(docker inspect --format {{.State.Pid}} munin) ip route show nsenter -n -t $(docker inspect --format {{.State.Pid}} munin) ping 192.168.111.11 ip route show