I am creating docker deluge-openvpn container i have already tried various deluge-openvpn container some works for me some does not
So i created this container using:
Docker-compose.yml
version: '3.8'
services:
deluge:
build: .
container_name: deluge-vpn
environment:
- PUID=1000
- PGID=1000
- TZ=Etc/UTC
- DELUGE_LOGLEVEL=error
volumes:
- /home/sammy/AppData/Deluge/config:/config
- /home/sammy/Downloads:/downloads
- /home/sammy/AppData/Deluge/vpn-config:/vpn-config
- /etc/localtime:/etc/localtime:ro
ports:
- 8112:8112
- 6881:6881
- 6881:6881/udp
- 58846:58846 #optional
cap_add:
- NET_ADMIN
devices:
- /dev/net/tun
restart: unless-stopped
Dockerfile
FROM lscr.io/linuxserver/deluge:latest
RUN apk add --no-cache openvpn
RUN mkdir -p /vpn-config
WORKDIR /vpn-config
COPY entrypoint.sh /usr/local/bin/
RUN chmod +x /usr/local/bin/entrypoint.sh
CMD ["/usr/local/bin/entrypoint.sh"]
entrypoint.sh
#!/bin/bash
# Add DNS
echo "nameserver 1.1.1.1" > /etc/resolv.conf
echo "nameserver 1.0.0.1" >> /etc/resolv.conf
# Check if OpenVPN configuration file exists and start OpenVPN if it does
if [ -f /vpn-config/vpn-config.ovpn ]; then
echo "Starting OpenVPN..."
openvpn --config /vpn-config/vpn-config.ovpn --auth-user-pass /vpn-config/vpn-credentials.txt --dev tun0 &
VPN_PID=$!
echo "OpenVPN started with PID ${VPN_PID}"
echo "Waiting for VPN connection to establish..."
sleep 10
# Fetch and display the IP address and location
echo "==================================================================="
echo "Fetching IP address and location..."
IP_INFO=$(curl -s ipinfo.io)
IP_ADDRESS=$(echo "$IP_INFO" | jq -r '.ip')
CITY=$(echo "$IP_INFO" | jq -r '.city')
REGION=$(echo "$IP_INFO" | jq -r '.region')
COUNTRY=$(echo "$IP_INFO" | jq -r '.country')
echo "IP Address: $IP_ADDRESS"
echo "Location: $CITY, $REGION, $COUNTRY"
echo "==================================================================="
else
echo "No OpenVPN configuration file found. Skipping OpenVPN startup...."
fi
# Keep the container running
tail -f /dev/null
When the vpn files are not added it works fine but when vpn is connected the deluge-ui is inaccessable using the http://:8112 but server is running inside the docker container
logs:
===================================================================
Fetching IP address and location...
IP Address: XX.XX.XX.XX
Location: Frankfurt am Main, Hesse, DE
===================================================================
root@93324a2eeeff:/vpn-config# ping 0.0.0.0:8112
PING 0.0.0.0:8112 (0.0.0.0): 56 data bytes
64 bytes from 127.0.0.1: seq=0 ttl=64 time=0.035 ms
64 bytes from 127.0.0.1: seq=1 ttl=64 time=0.036 ms
64 bytes from 127.0.0.1: seq=2 ttl=64 time=0.035 ms
64 bytes from 127.0.0.1: seq=3 ttl=64 time=0.044 ms
64 bytes from 127.0.0.1: seq=4 ttl=64 time=0.035 ms
64 bytes from 127.0.0.1: seq=5 ttl=64 time=0.036 ms
64 bytes from 127.0.0.1: seq=6 ttl=64 time=0.044 ms
^X64 bytes from 127.0.0.1: seq=7 ttl=64 time=0.041 ms
^C
--- 0.0.0.0:8112 ping statistics ---
8 packets transmitted, 8 packets received, 0% packet loss
round-trip min/avg/max = 0.035/0.038/0.044 ms
root@93324a2eeeff:/vpn-config# ping localhost:8112
PING localhost:8112 (::1): 56 data bytes
ping: sendto: Invalid argument
root@93324a2eeeff:/vpn-config# ping localhost:8112
PING localhost:8112 (::1): 56 data bytes
ping: sendto: Invalid argument
root@93324a2eeeff:/vpn-config# ping 127.0.0.1:8112
PING 127.0.0.1:8112 (127.0.0.1): 56 data bytes
64 bytes from 127.0.0.1: seq=0 ttl=64 time=0.035 ms
64 bytes from 127.0.0.1: seq=1 ttl=64 time=0.073 ms
64 bytes from 127.0.0.1: seq=2 ttl=64 time=0.033 ms
^C
--- 127.0.0.1:8112 ping statistics ---
3 packets transmitted, 3 packets received, 0% packet loss
round-trip min/avg/max = 0.033/0.047/0.073 ms
root@93324a2eeeff:/vpn-config#
I have already tried setting tun0 as default network interface and some other solutions as well.
Sorry, if I have done something wrong I am familiar with docker but not too much.