Wraps your program with ShadowsocksR network tunnel fully contained in Docker. Also exposes SOCKS5 server to host machine. This allows you to have multiple ShadowsocksR connections in different containers serving different programs running inside them through global proxy, or on host machine through SOCKS5 proxy.
Supports latest Docker for both Windows, Linux, and MacOS.
- openvpn-tunnel (GitHub) - Wraps your program with OpenVPN network tunnel fully contained in Docker.
- openvpn-socks5 (GitHub) - Convers OpenVPN connection to SOCKS5 server in Docker.
- shadowsocksr-tunnel (GitHub) - This project.
- It starts ShadowsocksR client mode
ss-redir
at default port of1024
. - It starts a SOCKS5 server at
$SOCKS5_PORT
, with optional authentication of$SOCKS5_USER
and$SOCKS5_PASS
. - It setups iptables rules to redirect all internet traffics initiated inside the container through the ShadowsocksR connection.
- It optionally runs the user specified CMD line from
docker run
positional arguments (see Docker doc). The program will use the ShadowsocksR connection inside the container. - If user has provided CMD line, and
DAEMON_MODE
environment variable is not set totrue
, then after running the CMD line, it will shutdown the ShadowsocksR client and SOCKS5 server, then terminate the container.
ShadowsocksR connection options are specified through these container environment variables:
SERVER_ADDR
(Default:"0.0.0.0"
) - remote server address, can either be a domain name or IP addressSERVER_PORT
(Default:"1080"
) - remote server portSERVER_PASS
(Default:""
) - remote server passwordMETHOD
(Default:"aes-256-ctr"
) - encryption methodPROTO
(Default:"auth_aes128_md5"
) - protocolPROTO_PARAM
(Default:""
) - protocol prarmeterOBFS
(Default:"plain"
) - obfuscationOBFS_PARAM
(Default:""
) - obfuscation parameterTIMEOUT
(Default:"300"
) - connection timeoutREDIR_PORT
(Default:"1024"
) -ss-redir
local listening port, must be different fromSOCKS5_PORT
SOCKS5 server options are specified through these container environment variables:
SOCKS5_PORT
(Default:"1080"
) - SOCKS5 server listening portSOCKS5_USER
(Default:""
) - SOCKS5 server authentication usernameSOCKS5_PASS
(Default:""
) - SOCKS5 server authentication password
Other container environment variables:
DAEMON_MODE
(Default:"false"
) - force enter daemon mode when CMD line is specifiedSOCKS5_UP
(Default:""
) - optional command to be executed when SOCKS5 server becomes stableSHADOWSOCKSR_UP
(Default:""
) - optional command to be executed when ShadowsocksR connection becomes stable
The following example will run curl ifconfig.co/json
through ShadowsocksR server 1.2.3.4
with other default settings.
docker run -it --rm --device=/dev/net/tun --cap-add=NET_ADMIN \
-e SERVER_ADDR="1.2.3.4" \
curve25519xsalsa20poly1305/shadowsocksr-tunnel \
curl ifconfig.co/json
You can leave the ShadowsocksR connection running in background, exposing its SOCKS5 server port to host port, and later use docker exec
to run your program inside the running container without ever closing and repoening your ShadowsocksR connection multiple times. Just leave out the CMD line when you start the container with docker run
, it will automatically enter daemon mode.
NAME="myssr"
PORT="7777"
docker run --name "${NAME}" -dit --rm --device=/dev/net/tun --cap-add=NET_ADMIN \
-e SERVER_ADDR="1.2.3.4" \
-p "${PORT}":1080 \
curve25519xsalsa20poly1305/shadowsocksr-tunnel \
curl ifconfig.co/json
Then you run commads using docker exec
:
NAME="myssr"
docker exec -it "${NAME}" curl ifconfig.co/json
Or use the SOCKS5 server available on host machine:
curl ifconfig.co/json -x socks5h://127.0.0.1:7777
To stop the daemon, run this:
NAME="myssr"
docker stop "${NAME}"
This image only includes curl
and wget
for most basic HTTP request usage. If the program you want to run is not available in this image, you can easily extend this image to include anything you need.
Here is a very simple example Dockerfile
that will install aria2 in its derived image.
FROM curve25519xsalsa20poly1305/shadowsocksr-tunnel
RUN apk add --no-cache aria2
Build this image with:
# Unix & Windows
docker build -t shadowsocksr-aria2 .
Finally run it with
docker run -it --rm --device=/dev/net/tun --cap-add=NET_ADMIN \
-e SERVER_ADDR="1.2.3.4" \
-v "${PWD}":/downloads:rw \
-w /downloads \
shadowsocksr-aria2 \
arai2c http://example.com/index.html
It will download the file using aria2c
to your host's current directory.
Please feel free to contribute to this project. But before you do so, just make sure you understand the following:
1. Make sure you have access to the official repository of this project where the maintainer is actively pushing changes. So that all effective changes can go into the official release pipeline.
2. Make sure your editor has EditorConfig plugin installed and enabled. It's used to unify code formatting style.
3. Use Conventional Commits 1.0.0-beta.2 to format Git commit messages.
4. Use Gitflow as Git workflow guideline.
5. Use Semantic Versioning 2.0.0 to tag release versions.
Copyright © 2019 curve25519xsalsa20poly1305 <[email protected]>
This work is free. You can redistribute it and/or modify it under the terms of the Do What The Fuck You Want To Public License, Version 2, as published by Sam Hocevar. See the COPYING file for more details.