Skip to content

Commit b8341dd

Browse files
authored
Add docker-compose examples (ngoduykhanh#339)
1 parent 7b848c8 commit b8341dd

File tree

7 files changed

+151
-12
lines changed

7 files changed

+151
-12
lines changed

.dockerignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,3 +25,6 @@ docker-compose*
2525
db
2626
assets
2727
wireguard-ui
28+
29+
# Examples
30+
examples

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,3 +21,7 @@ rice-box.go
2121
# IDEs
2222
.vscode
2323
.idea
24+
25+
# Examples
26+
examples/docker-compose/config
27+
examples/docker-compose/db

README.md

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -27,23 +27,13 @@ Download the binary file from the release page and run it directly on the host m
2727

2828
### Using docker compose
2929

30-
You can take a look at this example
31-
of [docker-compose.yml](https://github.com/ngoduykhanh/wireguard-ui/blob/master/docker-compose.yaml). Please adjust
32-
volume mount points to work with your setup. Then run it like below:
30+
The [examples/docker-compose](examples/docker-compose) folder contains example docker-compose files.
31+
Choose the example which fits you the most, adjust the configuration for your needs, then run it like below:
3332

3433
```
3534
docker-compose up
3635
```
3736

38-
Note:
39-
40-
- There is a Status page that needs docker to be able to access the network of the host in order to read the
41-
wireguard interface stats. See the `cap_add` and `network_mode` options on the docker-compose.yaml
42-
- Similarly, the `WGUI_MANAGE_START` and `WGUI_MANAGE_RESTART` settings need the same access, in order to restart the
43-
wireguard interface.
44-
- Because the `network_mode` is set to `host`, we don't need to specify the exposed ports. The app will listen on
45-
port `5000` by default.
46-
4737
## Environment Variables
4838

4939
| Variable | Description | Default |

examples/docker-compose/README.md

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
## Prerequisites
2+
3+
### Kernel Module
4+
5+
Depending on if the Wireguard kernel module is available on your system you have more or less choices which example to use.
6+
7+
You can check if the kernel modules are available via the following command:
8+
```shell
9+
modprobe wireguard
10+
```
11+
12+
If the command exits successfully and doesn't print an error the kernel modules are available.
13+
If it does error, you either have to install them manually (or activate if deactivated) or use an userspace implementation.
14+
For an example of an userspace implementation, see _borigtun_.
15+
16+
### Credentials
17+
18+
Username and password for all examples is `admin` by default.
19+
For security reasons it's highly recommended to change them before the first startup.
20+
21+
## Examples
22+
- **[system](system.yml)**
23+
24+
If you have Wireguard already installed on your system and only want to run the UI in docker this might fit the most.
25+
- **[linuxserver](linuxserver.yml)**
26+
27+
If you have the Wireguard kernel modules installed (included in the mainline kernel since version 5.6) but want it running inside of docker, this might fit the most.
28+
- **[boringtun](boringtun.yml)**
29+
30+
If Wireguard kernel modules are not available, you can switch to an userspace implementation like [boringtun](https://github.com/cloudflare/boringtun).

examples/docker-compose/boringtun.yml

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
version: "3"
2+
3+
services:
4+
boringtun:
5+
image: ghcr.io/ntkme/boringtun:edge
6+
command:
7+
- wg0
8+
container_name: boringtun
9+
# use the network of the 'wireguard-ui' service. this enables to show active clients in the status page
10+
network_mode: service:wireguard-ui
11+
cap_add:
12+
- NET_ADMIN
13+
volumes:
14+
- /dev/net/tun:/dev/net/tun
15+
- ./config:/etc/wireguard
16+
17+
wireguard-ui:
18+
image: ngoduykhanh/wireguard-ui:latest
19+
container_name: wireguard-ui
20+
cap_add:
21+
- NET_ADMIN
22+
environment:
23+
- SENDGRID_API_KEY
24+
- EMAIL_FROM_ADDRESS
25+
- EMAIL_FROM_NAME
26+
- SESSION_SECRET
27+
- WGUI_USERNAME=admin
28+
- WGUI_PASSWORD=admin
29+
- WG_CONF_TEMPLATE
30+
- WGUI_MANAGE_START=true
31+
- WGUI_MANAGE_RESTART=true
32+
logging:
33+
driver: json-file
34+
options:
35+
max-size: 50m
36+
volumes:
37+
- ./db:/app/db
38+
- ./config:/etc/wireguard
39+
ports:
40+
# port for wireguard-ui
41+
- "5000:5000"
42+
# port of the wireguard server. this must be set here as the `boringtun` container joins the network of this container and hasn't its own network over which it could publish the ports
43+
- "51820:51820/udp"
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
version: "3"
2+
3+
services:
4+
wireguard:
5+
image: linuxserver/wireguard:latest
6+
container_name: wireguard
7+
cap_add:
8+
- NET_ADMIN
9+
volumes:
10+
- ./config:/config
11+
ports:
12+
# port for wireguard-ui. this must be set here as the `wireguard-ui` container joins the network of this container and hasn't its own network over which it could publish the ports
13+
- "5000:5000"
14+
# port of the wireguard server
15+
- "51820:51820/udp"
16+
17+
wireguard-ui:
18+
image: ngoduykhanh/wireguard-ui:latest
19+
container_name: wireguard-ui
20+
depends_on:
21+
- wireguard
22+
cap_add:
23+
- NET_ADMIN
24+
# use the network of the 'wireguard' service. this enables to show active clients in the status page
25+
network_mode: service:wireguard
26+
environment:
27+
- SENDGRID_API_KEY
28+
- EMAIL_FROM_ADDRESS
29+
- EMAIL_FROM_NAME
30+
- SESSION_SECRET
31+
- WGUI_USERNAME=admin
32+
- WGUI_PASSWORD=admin
33+
- WG_CONF_TEMPLATE
34+
- WGUI_MANAGE_START=true
35+
- WGUI_MANAGE_RESTART=true
36+
logging:
37+
driver: json-file
38+
options:
39+
max-size: 50m
40+
volumes:
41+
- ./db:/app/db
42+
- ./config:/etc/wireguard

examples/docker-compose/system.yml

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
version: "3"
2+
3+
services:
4+
wireguard-ui:
5+
image: ngoduykhanh/wireguard-ui:latest
6+
container_name: wireguard-ui
7+
cap_add:
8+
- NET_ADMIN
9+
# required to show active clients. with this set, you don't need to expose the ui port (5000) anymore
10+
network_mode: host
11+
environment:
12+
- SENDGRID_API_KEY
13+
- EMAIL_FROM_ADDRESS
14+
- EMAIL_FROM_NAME
15+
- SESSION_SECRET
16+
- WGUI_USERNAME=admin
17+
- WGUI_PASSWORD=admin
18+
- WG_CONF_TEMPLATE
19+
- WGUI_MANAGE_START=false
20+
- WGUI_MANAGE_RESTART=false
21+
logging:
22+
driver: json-file
23+
options:
24+
max-size: 50m
25+
volumes:
26+
- ./db:/app/db
27+
- /etc/wireguard:/etc/wireguard

0 commit comments

Comments
 (0)