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

Docker Solution of WGDashboard #272

Open
enriluis opened this issue May 24, 2024 · 30 comments
Open

Docker Solution of WGDashboard #272

enriluis opened this issue May 24, 2024 · 30 comments
Labels
enhancement New feature or request

Comments

@enriluis
Copy link

Is your feature request related to a problem? Please describe.
This project should have a Docker image and be able to be deployed in Docker. docker pull wgdashboard and pass env mount vol integrate with wireguard container
Describe the solution you'd like
A clear and concise description of what you want to happen.

@enriluis enriluis added the enhancement New feature or request label May 24, 2024
@DaanSelen
Copy link
Collaborator

DaanSelen commented Jun 3, 2024

https://hub.docker.com/r/donaldzou/wgdashboard/

Is this not what you mean? I will also try to make one with the new version of WGDash.

@DaanSelen
Copy link
Collaborator

If possible please assign me

@donaldzou
Copy link
Owner

Hi all! Thank you for bringing this up. Not gonna lie I'm not a Docker user or an expert at all (i tried but failed) lol. If you have a good solution please let me know. I'm happy to provide help as I can :)

@donaldzou
Copy link
Owner

https://hub.docker.com/r/donaldzou/wgdashboard/

Is this not what you mean? I will also try to make one with the new version of WGDash.

Yes this is what I meant i tried lol. Everytime when it restart, everything will just be gone, I couldn't figure out how to preserve data from previous session.

@DaanSelen
Copy link
Collaborator

DaanSelen commented Jun 4, 2024

https://hub.docker.com/r/donaldzou/wgdashboard/
Is this not what you mean? I will also try to make one with the new version of WGDash.

Yes this is what I meant i tried lol. Everytime when it restart, everything will just be gone, I couldn't figure out how to preserve data from previous session.

Please can you provide the information: Where is the data regarding matching peers from the wg0.conf to actual readable names stored by WireGuard Dashboard? Other than that, I have a functioning container. Doing some more devving. Persistency seems to work now.

@donaldzou
Copy link
Owner

donaldzou commented Jun 5, 2024 via email

@DaanSelen
Copy link
Collaborator

DaanSelen commented Jun 5, 2024

Hi!👋🏻 So usually WireGuard will read the configuration at /etc/wireguard and it will use the file name as the configuration name. In some rare case it will generate a config name. So the dashboard will just read those file directly to get the data. Best, Donald Get Outlook for iOShttps://aka.ms/o0ukef

________________________________ From: dselen @.> Sent: Wednesday, June 5, 2024 4:44:40 AM To: donaldzou/WGDashboard @.> Cc: Donald Zou @.>; Comment @.> Subject: Re: [donaldzou/WGDashboard] Docker image (Issue #272) https://hub.docker.com/r/donaldzou/wgdashboard/ Is this not what you mean? I will also try to make one with the new version of WGDash. Yes this is what I meant i tried lol. Everytime when it restart, everything will just be gone, I couldn't figure out how to preserve data from previous session. Please can you provide the information: Where is the data regarding matching peers from the wg0.conf to actual readable names stored by WireGuard Dashboard? Other than that, I have a functioning container. Doing some more devving. — Reply to this email directly, view it on GitHub<#272 (comment)>, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AGARNUMKGHTDFCKHFDULPJ3ZFYRLRAVCNFSM6AAAAABIIAGXTOVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDCNBYGM4DKNZRGI. You are receiving this because you commented.Message ID: @.***>

What I meant, is WGDash seems to store the public key to readable name somewhere. Wireguard configs do not store that by default. Either WGDash comments it in the wg0.conf or there is a file somewhere that keeps track of the names of the public keys, correct? Right now I just did it through persisting the /src directory.

For current state of the container; https://github.com/DaanSelen/WGDashboard-dockerized/tree/main/docker
You can also pull the image and run it from (temporarily) repo.nerthus.nl/app/wireguard-dashboard:latest (However this repo of mine is subject to change).

@DaanSelen
Copy link
Collaborator

DaanSelen commented Jun 7, 2024

Hello everyone! I have been working on the docker image and I feel good about releasing or at least making known its docker pull-able from my own registry. For now, please refer to the compose.yaml file for instructions. I will be working on the markdown file in that directory soon.

More info (such as the compose.yaml/docker-compose.yaml) and source-code here:
https://github.com/DaanSelen/WGDashboard-dockerized/tree/main/docker

If you want to pull the image, use (for now) docker pull repo.nerthus.nl/app/wireguard-dashboard:latest.

Anyone willing to use or test the image, please give me feedback if you encounter something. You can always submit an issue on my forked repository or comment here.

@donaldzou I am curious to what your opinion will be. Persistency works through Docker Volumes, which remembers the state of the application after restarts AND recreations of the entire container, as long as the volumes are references correctly.
@ikidd If you still work with docker, and since you were the previous creator. Please review, if willing.

Kind regards, Daan Selen.

@donaldzou
Copy link
Owner

Hi!👋🏻 So usually WireGuard will read the configuration at /etc/wireguard and it will use the file name as the configuration name. In some rare case it will generate a config name. So the dashboard will just read those file directly to get the data. Best, Donald Get Outlook for iOShttps://aka.ms/o0ukef

________________________________ From: dselen @.> Sent: Wednesday, June 5, 2024 4:44:40 AM To: donaldzou/WGDashboard _@**._> Cc: Donald Zou _@.>; Comment @._> Subject: Re: [donaldzou/WGDashboard] Docker image (Issue #272) https://hub.docker.com/r/donaldzou/wgdashboard/ Is this not what you mean? I will also try to make one with the new version of WGDash. Yes this is what I meant i tried lol. Everytime when it restart, everything will just be gone, I couldn't figure out how to preserve data from previous session. Please can you provide the information: Where is the data regarding matching peers from the wg0.conf to actual readable names stored by WireGuard Dashboard? Other than that, I have a functioning container. Doing some more devving. — Reply to this email directly, view it on GitHub<#272 (comment)>, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AGARNUMKGHTDFCKHFDULPJ3ZFYRLRAVCNFSM6AAAAABIIAGXTOVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDCNBYGM4DKNZRGI. You are receiving this because you commented.Message ID: _@_.*>

What I meant, is WGDash seems to store the public key to readable name somewhere. Wireguard configs do not store that by default. Either WGDash comments it in the wg0.conf or there is a file somewhere that keeps track of the names of the public keys, correct? Right now I just did it through persisting the /src directory.

For current state of the container; https://github.com/DaanSelen/WGDashboard-dockerized/tree/main/docker You can also pull the image and run it from (temporarily) repo.nerthus.nl/app/wireguard-dashboard:latest (However this repo of mine is subject to change).

Ahhh I see, currently everything is stored in a SQLite database under src/db/wgdashboard.db

@donaldzou
Copy link
Owner

Hi @DaanSelen ! Thank you for working on the docker image. I will test it in few days and get back to you. I'm not familiar with Docker, but in my imagination, the image should create a Linux system, install it somewhere that won't remove after pausing the image.. kinda like a VM but running in Docker? correct me if i'm wrong lol.

@DaanSelen
Copy link
Collaborator

DaanSelen commented Jun 7, 2024

Hi @DaanSelen ! Thank you for working on the docker image. I will test it in few days and get back to you. I'm not familiar with Docker, but in my imagination, the image should create a Linux system, install it somewhere that won't remove after pausing the image.. kinda like a VM but running in Docker? correct me if i'm wrong lol.

Hi there, some help to get everyone started:

If you have Docker and Docker Compose installed, skip to step: 4.

Here are the instructions:

  1. Install a Linux system, you can choose the distribution yourself. You can also emulate/virtualize it on Windows using VMware Player or Oracle VirtualBox.
  2. Install Docker on that Linux system, ref: https://docs.docker.com/engine/install/
  3. Once Docker is installed, you can if you can run the command docker compose
  4. Once that works, copy only the compose.yaml from my fork of your repository. Its in the repository's /docker folder, ref: https://github.com/DaanSelen/WGDashboard-dockerized/blob/main/docker/compose.yaml
  5. Change the values in the compose if you want some specific things, or one of the features I built into the container. I really hope my tips in the file itself will help! If not, please tell me.
  6. Make sure you are in the same directory as the compose.yaml file. Then fill in docker compose up -d (This executes the instructions I have precompiled for the interface, -d meaning --detached, a.k.a. in the background).
  7. You should see the container alive and preferably with a (healthy) (if all is working as intended) mark behind the name when you type docker ps
  8. Ports 10086 and 51820 are being used by that container, if you did not change them in the compose file.
  9. Checking persistency is done through the docker volume ls command, you should see two entries. conf and app, these are stored on the system at /var/lib/docker/volumes if I am not mistaken.

Hopefully you can manage with these instructions! And if you like the result, I'd love to help contribute my knowledge to this project!

For other willing to test the image, everyone can follow these above instructions.
Kind regards, Daan Selen.

@DaanSelen
Copy link
Collaborator

Hi!👋🏻 So usually WireGuard will read the configuration at /etc/wireguard and it will use the file name as the configuration name. In some rare case it will generate a config name. So the dashboard will just read those file directly to get the data. Best, Donald Get Outlook for iOShttps://aka.ms/o0ukef

________________________________ From: dselen @.> Sent: Wednesday, June 5, 2024 4:44:40 AM To: donaldzou/WGDashboard _@**._> Cc: Donald Zou _@.>; Comment @._> Subject: Re: [donaldzou/WGDashboard] Docker image (Issue #272) https://hub.docker.com/r/donaldzou/wgdashboard/ Is this not what you mean? I will also try to make one with the new version of WGDash. Yes this is what I meant i tried lol. Everytime when it restart, everything will just be gone, I couldn't figure out how to preserve data from previous session. Please can you provide the information: Where is the data regarding matching peers from the wg0.conf to actual readable names stored by WireGuard Dashboard? Other than that, I have a functioning container. Doing some more devving. — Reply to this email directly, view it on GitHub<#272 (comment)>, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AGARNUMKGHTDFCKHFDULPJ3ZFYRLRAVCNFSM6AAAAABIIAGXTOVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDCNBYGM4DKNZRGI. You are receiving this because you commented.Message ID: _@_.*>

What I meant, is WGDash seems to store the public key to readable name somewhere. Wireguard configs do not store that by default. Either WGDash comments it in the wg0.conf or there is a file somewhere that keeps track of the names of the public keys, correct? Right now I just did it through persisting the /src directory.
For current state of the container; https://github.com/DaanSelen/WGDashboard-dockerized/tree/main/docker You can also pull the image and run it from (temporarily) repo.nerthus.nl/app/wireguard-dashboard:latest (However this repo of mine is subject to change).

Ahhh I see, currently everything is stored in a SQLite database under src/db/wgdashboard.db

I will see what I can do for trimming down the used space.

@DaanSelen
Copy link
Collaborator

Image can be closed, right @enriluis ?

@shuricksumy
Copy link

Hi,

I tried to run v4 in the docker for personal purposes and testing.
I updated a bit scripts and it works.
It's just a draft and I will continue to improve it.
If it can help, please reuse what you need.

Link is docker-wgdashboard

@donaldzou
Copy link
Owner

Hi,

I tried to run v4 in the docker for personal purposes and testing.

I updated a bit scripts and it works.

It's just a draft and I will continue to improve it.

If it can help, please reuse what you need.

Link is docker-wgdashboard

@shuricksumy hi! Thanks for providing this. If I understand correctly, the dockerfile will only expose port 10086(dashboard) and 51820(wg)? So if I want to create a new wg config with port 51821, do I need to manually change the dockerfile?

@shuricksumy
Copy link

Hi,
I tried to run v4 in the docker for personal purposes and testing.
I updated a bit scripts and it works.
It's just a draft and I will continue to improve it.
If it can help, please reuse what you need.
Link is docker-wgdashboard

@shuricksumy hi! Thanks for providing this. If I understand correctly, the dockerfile will only expose port 10086(dashboard) and 51820(wg)? So if I want to create a new wg config with port 51821, do I need to manually change the dockerfile?

Good point,
I think it's possible to forward range of ports, like this
ports:

  • "51820-51830:51820-51830"

So it will allow having some range of open ports for new wg_.conf configurations,
But I haven't tested this yet.

@DaanSelen
Copy link
Collaborator

Hi,
I tried to run v4 in the docker for personal purposes and testing.
I updated a bit scripts and it works.
It's just a draft and I will continue to improve it.
If it can help, please reuse what you need.
Link is docker-wgdashboard

@shuricksumy hi! Thanks for providing this. If I understand correctly, the dockerfile will only expose port 10086(dashboard) and 51820(wg)? So if I want to create a new wg config with port 51821, do I need to manually change the dockerfile?

Good point,
I think it's possible to forward range of ports, like this
ports:

  • "51820-51830:51820-51830"

So it will allow having some range of open ports for new wg_.conf configurations,
But I haven't tested this yet.

Hey just to clarify, I made the image to have a template and work out of the box. You can add multiple configs by openings ports and adding the config using docker cp or placing it into the var/lib/docker/volumes.

@DaanSelen
Copy link
Collaborator

Hi,

I tried to run v4 in the docker for personal purposes and testing.
I updated a bit scripts and it works.
It's just a draft and I will continue to improve it.
If it can help, please reuse what you need.

Link is docker-wgdashboard

Hey there, lookz very good and interesting! Can you explain why you did the changes you did?

@shuricksumy
Copy link

Hi,
I tried to run v4 in the docker for personal purposes and testing.
I updated a bit scripts and it works.
It's just a draft and I will continue to improve it.
If it can help, please reuse what you need.
Link is docker-wgdashboard

Hey there, lookz very good and interesting! Can you explain why you did the changes you did?

Hi, I did not much to just run it

  1. I added symbol link to venv directory - it's like quick solution but docker builder does it in one place but wgd.sh uses it from another place
# Create symbolic link to the virtual environment
RUN ln -s ${WGDASH}/venv ${WGDASH}/app/src/venv \
  && mkdir -p ${WGDASH}/app/src/log
  1. I changed HEALTHCHECK
    CMD curl -s -o /dev/null -w "%{http_code}" http://localhost:10086/signin | grep -q "401" && exit 0 || exit 1
  2. I added script to run WG interface using this var
    - ENABLE=wg0,wg1,wg2
  3. I added script to use vars, as there is no possibility to edit it in on web yet
- WG0_POST_UP
- WG0_POST_DOWN
  1. Changed some vars to capital letters

It looks like these are all changes I did.

But also I looking to easy way to add prefix for web endpoint to easy use proxy forwarding
like: http://localhost:10086/{some_prefix}/

@DaanSelen
Copy link
Collaborator

Hi,
I tried to run v4 in the docker for personal purposes and testing.
I updated a bit scripts and it works.
It's just a draft and I will continue to improve it.
If it can help, please reuse what you need.
Link is docker-wgdashboard

Hey there, lookz very good and interesting! Can you explain why you did the changes you did?

Hi, I did not much to just run it

  1. I added symbol link to venv directory - it's like quick solution but docker builder does it in one place but wgd.sh uses it from another place
# Create symbolic link to the virtual environment
RUN ln -s ${WGDASH}/venv ${WGDASH}/app/src/venv \
  && mkdir -p ${WGDASH}/app/src/log
  1. I changed HEALTHCHECK
    CMD curl -s -o /dev/null -w "%{http_code}" http://localhost:10086/signin | grep -q "401" && exit 0 || exit 1
  2. I added script to run WG interface using this var
    - ENABLE=wg0,wg1,wg2
  3. I added script to use vars, as there is no possibility to edit it in on web yet
- WG0_POST_UP
- WG0_POST_DOWN
  1. Changed some vars to capital letters

It looks like these are all changes I did.

But also I looking to easy way to add prefix for web endpoint to easy use proxy forwarding like: http://localhost:10086/{some_prefix}/

And the easy way to add the prefix is with the added build stage I assume. I saw some changes to the bash script yeah. I am not familiar with why the symlink is needed but if it does not hurt why not.

I also looked through the changes and it looks good! I see you used a couple different ways of getting variables but if it works and is practical then sure.

@shuricksumy
Copy link

shuricksumy commented Aug 13, 2024

I am not familiar with why the symlink is needed but if it does not hurt why not.

It was just quick fix
I've tested, we can just correct some files and it works directly with ${WGDASH}/app/src/venv

Dockerfile

# Copy the WGDashboard repository from the local filesystem into the container
COPY ./WGDashboard ${WGDASH}/app

# Set up Python virtual environment
RUN python3 -m venv ${WGDASH}/app/src/venv \
  && mkdir -p ${WGDASH}/app/src/log

# Install Python dependencies
RUN . ${WGDASH}/app/src/venv/bin/activate \
  && pip3 install -r ${WGDASH}/app/src/requirements.txt \
  && chmod +x ${WGDASH}/app/src/wgd.sh \
  && ${WGDASH}/app/src/wgd.sh install

entrypoint.sh

 echo "Activating Python virtual environment and starting WireGuard Dashboard service."
    . "${WGDASH}/app/src/venv/bin/activate"
    cd "${WGDASH}/app/src" || { echo "Failed to change directory. Exiting."; return; }
    bash wgd.sh start

@shuricksumy
Copy link

Hi, @DaanSelen
Just let you know, @donaldzou added supporting url_prefix,
I played a bit with that and updated docker builder for it.
It can be reused if need. Link

@Luca1996O
Copy link

Luca1996O commented Aug 18, 2024

@shuricksumy to let your Docker compose works, I had to change this:

volumes:
      - ./scripts:/scripts
      - ./conf:/etc/wireguard
      - ./log:/opt/wireguarddashboard/app/src/log
      - ./db:/opt/wireguarddashboard/app/src/db
      # touch ./ini/wg-dashboard.ini
      - ./ini/wg-dashboard.ini:/opt/wireguarddashboard/app/src/wg-dashboard.ini

to this:

volumes:
      - ./scripts:/scripts
      - ./conf:/etc/wireguard
      - ./log:/opt/wireguarddashboard/app/src/log
      - ./db:/opt/wireguarddashboard/app/src/db
      - ./ini:/opt/wireguarddashboard/app/src/ini

Otherwise I had error "IsADirectoryError: [Errno 21] Is a directory: './wg-dashboard.ini'".

I hope this helps.
Thank you.

@shuricksumy
Copy link

shuricksumy commented Aug 18, 2024

Otherwise I had error "IsADirectoryError: [Errno 21] Is a directory: './wg-dashboard.ini'".

This error is due to no empty file (wg-dashboard.ini) before docker compose run first time. Need to creare it firstly. (# touch ./ini/wg-dashboard.ini)

As to your idea to mount direcotory ini, I will check it. Before ini file was located in src directory. So I will try to create some workaround in start script to handle this case automatically.

@shuricksumy
Copy link

shuricksumy commented Aug 18, 2024

@Luca1996O
I updated my Docker builder and docker compose file
Now configuration files are stored in app_conf
- ./app_conf:/opt/wireguarddashboard/app/src/app_conf

So it will be created automatically. There are ini file and DB folder there.
Please be aware that it needs be replaced manually ([wg-dashboard.ini, db] -> ./app_conf/ ) if you already have config files

@Luca1996O
Copy link

Luca1996O commented Aug 19, 2024

@Luca1996O I updated my Docker builder and docker compose file Now configuration files are stored in app_conf - ./app_conf:/opt/wireguarddashboard/app/src/app_conf

So it will be created automatically. There are ini file and DB folder there. Please be aware that it needs be replaced manually ([wg-dashboard.ini, db] -> ./app_conf/ ) if you already have config files

Thank you very much!

How can I let it detect my public IP automatically (using ifconfig.me)? Because I tried to put 0.0.0.0 in Public IP (in Docker compose code) but it doesn't work. I tried the same in the dashboard, but it still doesn't detect it.

I need it because I've got a dynamic IP and I'd like to make sure that it changes it automatically in case the connection drops, without using any DNS.

P.S. Plus, after rebooting container dashboard being unaccessible, saying "Unauthorized - 401". Same on a new installation.

@shuricksumy
Copy link

shuricksumy commented Aug 19, 2024

How can I let it detect my public IP automatically (using ifconfig.me)? Because I tried to put 0.0.0.0 in Public IP (in Docker compose code) but it doesn't work. I tried the same in the dashboard, but it still doesn't detect it.

I need it because I've got a dynamic IP and I'd like to make sure that it changes it automatically in case the connection drops, without using any DNS.

P.S. Plus, after rebooting container dashboard being unaccessible, saying "Unauthorized - 401". Same on a new installation.

Hi,

Public IP here is a part of config, and it's setup first time when you deploy docker and if you not set it in env vars predefined.

So in case of dynamic IP, it's a good question)) just because server endpoints to connect peers are listening on this IP and in case it changed you need new peers configuration on client side - just let them know where they should connect. May be here can be used host name with dynamic IP like for example noip.com provides. But I haven't test or uesd it.
In case Unauthorized - maybe session is also connected to IP that's why you got this.

The idea to have VPN for personal usage is just brilliant when you have some tiny virtual machine on Amazon or DigitalOcean. They provide static IP and it can be reachable from any your devices and this devices can communicate each other even over the NAT or grey IP of providers. It costs about 7$ per month to have this virtual machine in cloud.

@DaanSelen
Copy link
Collaborator

How can I let it detect my public IP automatically (using ifconfig.me)? Because I tried to put 0.0.0.0 in Public IP (in Docker compose code) but it doesn't work. I tried the same in the dashboard, but it still doesn't detect it.

I need it because I've got a dynamic IP and I'd like to make sure that it changes it automatically in case the connection drops, without using any DNS.

P.S. Plus, after rebooting container dashboard being unaccessible, saying "Unauthorized - 401". Same on a new installation.

Hi,

Public IP here is a part of config, and it's setup first time when you deploy docker and if you not set it in env vars predefined.

So in case of dynamic IP, it's a good question)) just because server endpoints to connect peers are listening on this IP and in case it changed you need new peers configuration on client side - just let them know where they should connect. May be here can be used host name with dynamic IP like for example noip.com provides. But I haven't test or uesd it.
In case Unauthorized - maybe session is also connected to IP that's why you got this.

The idea to have VPN for personal usage is just brilliant when you have some tiny virtual machine on Amazon or DigitalOcean. They provide static IP and it can be reachable from any your devices and this devices can communicate each other even over the NAT or grey IP of providers. It costs about 7$ per month to have this virtual machine in cloud.

Hi there, if I may ask, which docker solution are you using? I think we have 2 versions, and I dont know if the versions process the information differently?

@shuricksumy
Copy link

Hi there, if I may ask, which docker solution are you using? I think we have 2 versions, and I dont know if the versions process the information differently?

I am using and testing my own one: here https://github.com/shuricksumy/docker-wgdashboard

@DaanSelen
Copy link
Collaborator

@shuricksumy

I have created a new fork for Version 4 of WGDashboard here: https://github.com/DaanSelen/WGDashboard and working through a couple of the features you suggested or made in your own repository, please provide me some feedback if you have time.

@DaanSelen DaanSelen unpinned this issue Aug 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

5 participants