Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Is it possible to use WireGuard in Docker as well? #85

Open
bikeymouse opened this issue Jun 16, 2021 · 4 comments
Open

Is it possible to use WireGuard in Docker as well? #85

bikeymouse opened this issue Jun 16, 2021 · 4 comments

Comments

@bikeymouse
Copy link

I'm trying to get this wg-gen web to connect to my Wireguard installation that also runs in Docker using the Linux-server Docker container..

However I'm having issues to get the API working, probably because it needs access to WireGuard inside the other container. Also I guess that if wg-gen web is updating the config it should be able trigger a restart of the WireGuard container or something, to have the config reloaded.

So I'm wondering if this even possible, or shouldn't I even try this? It would be great if we could have a single docker-compose template that would install Wireguard + WG Gen including the API in one go!

@vx3r
Copy link
Owner

vx3r commented Jun 16, 2021

The container u are using is already managing the peers config creation.
Also I guess that if wg-gen web is updating the config it should be able trigger a restart of the WireGuard container or something, to have the config reloaded. actually no, consider reading the whole readme please

It would be great if we could have a single docker-compose template that would install Wireguard + WG Gen including the API in one go!

What is the point of having WireGuard """inside""" the container ? Wireguard is a kernel module

@bikeymouse
Copy link
Author

The container u are using is already managing the peers config creation.

Yes, but not via a web-interface and without any stats. That's why I was looking at wg-gen web to complement that.

[Also I guess that if wg-gen web is updating the config it should be able trigger a restart of the WireGuard container or something, to have the config reloaded. consider reading the whole readme please

I think using systemd is not going to work as it tries to restart the WireGuard service. But that would be tried on the host, while Wireguard is running as a Docker container, so I would assume that this does not work. Or is that not correct?

It would be great if we could have a single docker-compose template that would install Wireguard + WG Gen including the API in one go!

What is the point of having WireGuard """inside""" the container ? Wireguard is a kernel module

The point is that with a Docker-based installation I can get WireGuard + WG-Gen Web installed, updated or deleted on any host (with Docker) in 5 seconds without any manual steps or downloads.

@vx3r
Copy link
Owner

vx3r commented Jun 16, 2021

okay i see. Wg Gen Web is generating standard WireGuard config files, its up to you to manage how WireGuard will pick them up.

The point is that with a Docker-based installation I can get WireGuard + WG-Gen Web installed, updated or deleted on any host (with Docker) in 5 seconds without any manual steps or downloads.

i was asking specifically about WireGuard, not docker in general. WireGuard is a kernel module and containers share the same kernel. Its like running iptables scripts firewall inside the container.

@NemesisRE
Copy link

I had the same wish so I added it the linuxserver.io way (https://www.linuxserver.io/blog/2019-09-14-customizing-our-containers)

in /config/custom-cont-init.d/ I created two scripts
inotify:

#!/usr/bin/with-contenv bash

echo "****** Installing inotifytools ******"
apt update
apt install inotify-tools -y

wg-api

#!/usr/bin/with-contenv bash

echo "****** Installing wg-api ******"
apt update
apt install golang-1.13 -y

git clone https://github.com/jamescun/wg-api.git /wg-api
cd /wg-api
GO_ENABLED=0 GOOS=linux /usr/lib/go-1.13/bin/go build -o wg-api cmd/wg-api.go
cp wg-api /app/
cd /
rm -rf wg-api

and another two in the /config/custom-services.d/
inotify:

#!/usr/bin/with-contenv bash

while inotifywait -e modify -e create /config; do
  wg-quick down wg0
  wg-quick up wg0
done

wg-api:

#!/usr/bin/with-contenv bash

exec \
    /app/wg-api --device wg0 --listen 0.0.0.0:8080

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants