A lightweight Docker image for running Lokinet as a SOCKS5 proxy - a decentralized, privacy-preserving network built on the Oxen blockchain.
This project provides an optimized Docker container that runs Lokinet as a SOCKS5 proxy, enabling you to route all your traffic through the Lokinet decentralized network with minimal configuration. Perfect for privacy-conscious users who want to leverage Lokinet’s anonymous routing capabilities through a simple Docker deployment.
git clone https://github.com/pasabanov/lokinet-proxy
cd lokinet-proxy
docker-compose.yml:
image: ghcr.io/pasabanov/lokinet-proxy:latest
docker-compose up -d
docker-compose logs lokinet
docker pull ghcr.io/pasabanov/lokinet-proxy:latest
docker run -d \
--name lokinet-proxy \
--cap-add NET_ADMIN \
--cap-add NET_BIND_SERVICE \
--device /dev/net/tun:/dev/net/tun \
--sysctl net.ipv6.conf.all.disable_ipv6=0 \
-p 127.0.0.1:1051:1051 \
-e SOCKS_PORT=1051 \
-e LOKINET_WORKER_THREADS=1 \
-e LOKINET_HOPS=3 \
-e LOKINET_PATHS=6 \
-e LOKINET_UPSTREAM_DNS=9.9.9.9 \
-e LOKINET_EXIT_NODE=exit.loki \
-v lokinet-data:/var/lib/lokinet \
--restart unless-stopped \
ghcr.io/pasabanov/lokinet-proxy:latest
SOCKS_PORT (default: 1051): The port on which the SOCKS5 proxy listens inside the containerLOKINET_WORKER_THREADS (default: 1): CPU thread limit for Lokinet daemon (1-2 recommended for VPS to prevent resource exhaustion)LOKINET_HOPS (default: 3): Number of routing hops (affects latency and anonymity; 3 is a balance point, default is 4)LOKINET_PATHS (default: 6): Number of backup paths (affects smoothness of path switching)LOKINET_UPSTREAM_DNS (default: 9.9.9.9): Public DNS server for fallback resolutionLOKINET_EXIT_NODE (default: exit.loki): Address and an optional ip range to use as an exit broker (the gateway to clearnet). Leave it empty to restrict any connections to clearnetThe docker-compose.yml file includes several important settings:
cap_add:
- NET_ADMIN # Allow container to configure network and routing (required for lokitun0)
- NET_BIND_SERVICE # Allow binding to lower SOCKS5 ports
devices:
- /dev/net/tun:/dev/net/tun # Required for Lokinet's virtual network interface
sysctls:
- net.ipv6.conf.all.disable_ipv6=0 # Lokinet requires IPv6 support
environment:
- SOCKS_PORT=1051
- LOKINET_WORKER_THREADS=1
- LOKINET_HOPS=3
- LOKINET_PATHS=6
- LOKINET_UPSTREAM_DNS=9.9.9.9
- LOKINET_EXIT_NODE=exit.loki
dns:
- 127.3.2.1 # For resolving .loki darknet domains
- 9.9.9.9 # Backup DNS for fallback to public internet
volumes:
- ./data:/var/lib/lokinet # Persists node keys and state to prevent identity reset after restart
By default, the SOCKS5 port is exposed to localhost only. Choose one of these approaches:
The default configuration exposes the port only to localhost:
ports:
- "127.0.0.1:1051:1051"
If using with Xray/Marzban on the same Docker network, comment out the ports section and access via lokinet:1051 directly:
# ports:
# - "127.0.0.1:1051:1051"
To connect to an existing Docker network:
networks:
default:
name: proxy_net
external: true
environment:
- LOKINET_WORKER_THREADS=1 # Limit CPU usage
- LOKINET_HOPS=2 # Reduce latency
- LOKINET_PATHS=4 # Reduce memory usage
environment:
- LOKINET_WORKER_THREADS=2 # More processing power
- LOKINET_HOPS=4 # More routing hops
- LOKINET_PATHS=8 # More backup paths
environment:
- LOKINET_WORKER_THREADS=1 # Default
- LOKINET_HOPS=3 # Default (recommended)
- LOKINET_PATHS=6 # Default
# Test SOCKS5 proxy (if port is exposed)
curl --socks5-hostname 127.0.0.1:1051 https://example.com
127.0.0.1:1051Additional settings for maximum privacy:
about:config pagenetwork.proxy.allow_bypassfalseIf running Xray/Marzban in the same Docker network:
# In your Xray config
"outbounds": [
{
"protocol": "socks",
"settings": {
"servers": [
{
"address": "lokinet",
"port": 1051
}
]
}
}
]
lokitun0 network interfacelokinet.ini from environment variables for worker threads, hops, and paths.loki domains via Lokinet’s DNS server (127.3.2.1) with fallback to public DNSlokitun0The docker-entrypoint.sh script performs the following steps:
/etc/resolv.conf) with Lokinet’s DNS server and fallback/var/lib/lokinet directory for node datalokinet.ini configuration file with environment variables:
worker-threads: CPU thread limithops: Routing hops for anonymitypaths: Backup path countupstream: Fallback DNS serverlokitun0 interface to become availableSOCKS_PORT environment variabledebian:bookworm-slimghcr.io/pasabanov/lokinet-proxy:latest - Latest releaseghcr.io/pasabanov/lokinet-proxy:1.2.3 - Specific versionghcr.io/pasabanov/lokinet-proxy:sha-abc1234 - Specific commit# Check logs
docker-compose logs lokinet
# Verify TUN device is available
ls -la /dev/net/tun
# Check if Dante is running
docker-compose exec lokinet ps aux | grep danted
# Test connectivity
docker-compose exec lokinet curl --socks5-hostname 127.0.0.1:1051 https://example.com
# Check DNS configuration inside container
docker-compose exec lokinet cat /etc/resolv.conf
# Test DNS resolution for .loki domains
docker-compose exec lokinet nslookup example.loki 127.3.2.1
If the container is consuming too much CPU:
# Reduce worker threads
docker-compose down
# Edit docker-compose.yml and set LOKINET_WORKER_THREADS=1
docker-compose up -d
If experiencing slow speeds:
# Try reducing hops for lower latency
# Edit docker-compose.yml and set LOKINET_HOPS=2
# Or increase paths for better path switching
# Edit docker-compose.yml and set LOKINET_PATHS=8
Ensure the host system supports IPv6 and the sysctl setting is applied:
docker-compose exec lokinet sysctl net.ipv6.conf.all.disable_ipv6
privileged: true)# Build the image
docker build -t lokinet-proxy:local .
# Run with Docker Compose
docker-compose up -d
See the LICENSE file.
Contributions are welcome! Feel free to submit issues and pull requests.
Privacy First - Route your traffic through a decentralized network with Lokinet Proxy.