Hello community.
I have been developing an extension for docker to make it possible to access some resources that exist ‘inside’ the docker system but can not directly be accessed on the host system.
These resources are:
- volumes
- networks
In the case of ‘native’ docker, all these resources are accessible, but in the case of volumes, not directly.
With my extension ‘docker gateway’ you can:
- get access to a ‘docker0’-like device making direct access to the container ip-addresses possible
- mount a docker volume to your local system, i.e. ‘the other way around’ than traditional mounts.
I’ve tested this on Linux using ‘native docker’ (i.e. context=default) and with docker desktop (i.e. context=desktop-linux) on both Linux and MacOS.
The requirements for the desktop-linux are a wireguard client and an nfs client.
Currently windows is not supported because i don’t have access to a windows system, but the logic should be implementable in windows.
I’d like to know if people are interested in this extension.
Best Regards,
Fred Gansevles.
---
# small example for docker desktop on linux
$ docker network inspect --format "{{(index .IPAM.Config 0).Gateway}}" bridge
172.18.0.1
$ ping ping 172.18.0.1 -c 3 -t 1
PING 172.18.0.1 (172.18.0.1) 56(84) bytes of data.
From 192.168.0.1 icmp_seq=1 Time to live exceeded
From 192.168.0.1 icmp_seq=2 Time to live exceeded
From 192.168.0.1 icmp_seq=3 Time to live exceeded
--- 172.18.0.1 ping statistics ---
3 packets transmitted, 0 received, +3 errors, 100% packet loss, time 2002ms
$ docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
$ docker gateway start
$ docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
105e15d09236 docker-gateway:latest "/docker-gateway.sh" 3 minutes ago Up 3 minutes (healthy) 127.0.0.1:2371->237/udp docker-gateway
$ ping 172.18.0.1 -c 3
PING 172.18.0.1 (172.18.0.1) 56(84) bytes of data.
64 bytes from 172.18.0.1: icmp_seq=1 ttl=63 time=1.42 ms
64 bytes from 172.18.0.1: icmp_seq=2 ttl=63 time=1.19 ms
64 bytes from 172.18.0.1: icmp_seq=3 ttl=63 time=1.10 ms
--- 172.18.0.1 ping statistics ---
3 packets transmitted, 3 received, 0% packet loss, time 2002ms
$ ip link show dev docker1
12: docker1: <POINTOPOINT,NOARP,UP,LOWER_UP> mtu 65456 qdisc noqueue state UNKNOWN mode DEFAULT group default qlen 1000
link/none
$ docker volume create data
data
$ mkdir data
$ df data
Filesystem 1K-blocks Used Available Use% Mounted on
/dev/nvme0n1p2 923847100 426397972 450446560 49% /
$ docker gateway volume data --mount $PWD/data
$ df data
Filesystem 1K-blocks Used Available Use% Mounted on
172.18.0.2:/volume/data 65739776 2745344 59622400 5% /home/fred/data
$ docker gateway volume data --umount $PWD/data
$ df data
Filesystem 1K-blocks Used Available Use% Mounted on
/dev/nvme0n1p2 923847100 426398832 450445700 49% /
$ docker gateway stop
$ docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
$ ip link show dev docker1
Device "docker1" does not exist.
$ ping 172.18.0.1 -c 3 -t 1
PING 172.18.0.1 (172.18.0.1) 56(84) bytes of data.
From 192.168.0.1 icmp_seq=2 Time to live exceeded
From 192.168.0.1 icmp_seq=3 Time to live exceeded
--- 172.18.0.1 ping statistics ---
3 packets transmitted, 0 received, +2 errors, 100% packet loss, time 2021ms