Wireguard client in container?

Did anybody manage to run a wireguard client in a container ?

Hey,

Personally no, I haven’t tried it and I am not up to speed on what might be special about Wireguard that should prevent it. I have run OpenVPN though, so principally it should work. Have you tried this out and failed, or just speculating at this point? It would be good to hear back if you have tried it :+1:

Wireguard requires a kernel module to be compiled and loaded and a network interface to be configured. OpenVPN is in user-space only so this is a different setup.

We are using Wireguard for other devices and I am trying to figure out how to integrate our Balena devices into that network. I can make this work but was wondering if there is an existing setup that I can use.

Hi, we have a project template for compiling kernel drivers and loading them from a container - https://github.com/balena-os/kernel-module-build. It compiles a simple “hello world” type of module, but you can adapt it for usage with Wireguard.

As for configuring the networking interface, you will probably need to run the container that sets up Wireguard in privileged mode and with network mode set to “host”.

Did you find any instructions how to achieve this?

No not yet

I would like to add here that I have today run Wireguard in a container, and used the demo server to pull the HTML from their example:

# curl -L http://192.168.4.1
    <title>WireGuard Demo Configuration: Success!</title>
    <body bgcolor="#444444">
    <script src="snowstorm.js"></script>
    <script src="trail.js"></script>
    <center>
    <blink>
    <marquee width="100%" behavior="alternate" direction="right" scrollamount="10">
    <marquee height="100%" behavior="alternate" direction="down">
    <marquee width="100%" bgcolor="#33aadd" direction="right" behavior="alternate"><font face="comic sans ms" size="7" style="font-size: 3vw" color="#ddaa33">Congrats! You've successfully configured WireGuard!</font><br><marquee scrollamount="30"><img src="emblem.svg" width="20%"></marquee><br><marquee direction="left" scrollamount="40" behavior="alternate"><script>document.write('<iframe frameborder="0" height="80%" width="70%" src="/?' + (((document.location.search.substring(1)|0) + 1) % 4) + '"></iframe>');</script></marquee><br><br></marquee>
    </marquee>
    </marquee>
    </blink>
    </center>
    </body>

I will try an prepare an article in the coming days detailing how to compile the module, loading it, etc so that you can try and move your projects forward :+1:

2 Likes

And did you ever get to the detailing part? :slightly_smiling_face:

No. Unfortunately not.

We have now published an article on our blog, which may help.