this repository provide docker compose samples to use wireguard image as server and client in difference to regular use cases, the setup build secure tunnel between containers only.
- wireguard image thanks to linuxserver.io
- github repo
documentation is fine, to implement my use case took several hours of digging and many attempts. maybe it helps someone else.
edit yaml to fit your preferences.
use id <your user name>
to find values for PUID
and PGID
.
id <your user name>
at first run start just wireguard server,
to build configuration files stored in volumne ./config
.
docker-compose -f wg-compose.yaml up -d wg-s1
now folder config
has been created
please edit peer1.conf
in section [Peer]
set Endpoint
to IP address of service wg-s1
.
Endpoint = 172.24.19.2:51820
to have matching compose yaml and documentation static
IP addresses have been assigned to network wgn-secured
and
to services,
let me know in case you have a better way.
:bulp: be aware changing environment variables (SERVERPORT, PEERS, PEERDNS, INTERNAL_SUBNET, ALLOWEDIPS) will trigger rebuild of configuration files
docker-compose -f wg-compose.yaml up -d wg-c1
using #vscode and docker extension,
simple Attach shell
on service wg-c1
and ping wireguard server
ping 10.16.19.1
using #vscode and docker extension,
simple Attach shell
on service wg-s1
and ping wireguard peer 1
ping 10.16.19.2
use wg show
to view wireguard tunnel.
wg show
docker-compose -f wg-compose.yaml up -d
docker-compose -f wg-compose.yaml down
wg show
ifconfig
ping 10.16.19.1
ping 10.16.19.2
ping 172.24.19.2
ping 172.24.19.3
ip route show
ip route add ...
linuxserver/docker-wireguard#139
iptables -L -v
date +"%Z %z"
timedatectl list-timezones
in case you want to wireshark container network, following repositories might interest you
- EdgeShark
- cshargextcap
- ghostWire
docker compose up -d
- PacketFix
- ghostWire
- https://github.com/linuxserver/docker-wireguard/blob/master/README.md
- https://hub.docker.com/r/linuxserver/wireguard#!
- https://www.linuxserver.io/blog/advanced-wireguard-container-routing
- https://www.linuxserver.io/blog/advanced-wireguard-hub
- https://linuxize.com/post/how-to-set-up-wireguard-vpn-on-centos-8/
- https://github.com/linuxserver/docker-wireguard
- https://linuxiac.com/how-to-set-up-wireguard-vpn-with-docker/
- https://www.smarthomebeginner.com/wireguard-docker-compose-guide-2023/
- https://docs.docker.com/samples/wireguard/
- https://www.linuxserver.io/blog/routing-docker-host-and-container-traffic-through-wireguard
- https://docs.techdox.nz/wireguard/#docker-compose-file-docker-composeyml
- https://docs.linuxserver.io/images/docker-wireguard/
- https://hub.docker.com/r/linuxserver/wireguard#!
- https://codeopolis.com/posts/installing-wireguard-in-docker/