├── .editorconfig ├── .gitignore ├── .travis.yml ├── 3.1 ├── Dockerfile └── docker-entrypoint.sh ├── 3.2 ├── Dockerfile └── docker-entrypoint.sh ├── LICENSE └── README.md /.editorconfig: -------------------------------------------------------------------------------- 1 | root = true 2 | 3 | [*] 4 | charset = utf-8 5 | end_of_line = lf 6 | insert_final_newline = true 7 | indent_style = space 8 | indent_size = 4 9 | trim_trailing_whitespace = true 10 | 11 | [*.sh] 12 | insert_final_newline = false 13 | indent_size = 2 14 | 15 | [*.md] 16 | trim_trailing_whitespace = false 17 | 18 | [*.yml] 19 | indent_size = 2 20 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # OS or Editor files 2 | ._* 3 | .DS_Store 4 | Thumbs.db 5 | .idea 6 | .project 7 | .settings 8 | .tmproj 9 | *.sublime-project 10 | *.sublime-workspace 11 | nbproject 12 | 13 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: bash 2 | services: docker 3 | 4 | env: 5 | - VERSION=3.1 6 | - VERSION=3.2 7 | 8 | install: 9 | - git clone https://github.com/docker-library/official-images.git ~/official-images 10 | 11 | before_script: 12 | - env | sort 13 | - cd "$VERSION" 14 | - image="cogset/shadowsocks:$VERSION" 15 | 16 | script: 17 | - docker build -t "$image" . 18 | - ~/official-images/test/run.sh "$image" 19 | 20 | after_script: 21 | - docker images 22 | -------------------------------------------------------------------------------- /3.1/Dockerfile: -------------------------------------------------------------------------------- 1 | # Shadowsocks 2 | # Cogset Open Source Group 3 | 4 | FROM debian:jessie 5 | 6 | MAINTAINER Cogset 7 | 8 | RUN groupadd -r shadowsocks && useradd -r -g shadowsocks shadowsocks 9 | 10 | ENV SHADOWSOCKS_VERSION v3.1.3 11 | 12 | # Install 13 | RUN buildDeps="wget autoconf make g++ libssl-dev libpcre3-dev ca-certificates" \ 14 | && apt-get update \ 15 | && apt-get install -y --no-install-recommends pwgen build-essential libtool asciidoc xmlto $buildDeps \ 16 | && wget -O shadowsocks.tar.gz "https://github.com/shadowsocks/shadowsocks-libev/archive/$SHADOWSOCKS_VERSION.tar.gz" \ 17 | && mkdir -p /usr/src/shadowsocks \ 18 | && tar -xzf shadowsocks.tar.gz -C /usr/src/shadowsocks --strip-components=1 \ 19 | && rm shadowsocks.tar.gz \ 20 | && cd /usr/src/shadowsocks \ 21 | && ./configure \ 22 | && make \ 23 | && make install \ 24 | && cd / \ 25 | && rm -rf /usr/src/shadowsocks \ 26 | && apt-get purge -y --auto-remove $buildDeps \ 27 | && rm -rf /var/lib/apt/lists/* 28 | 29 | COPY docker-entrypoint.sh /usr/local/bin/ 30 | RUN chmod +x /usr/local/bin/docker-entrypoint.sh 31 | 32 | ENTRYPOINT ["docker-entrypoint.sh"] 33 | 34 | EXPOSE 8989 35 | 36 | CMD ["ss-server"] 37 | -------------------------------------------------------------------------------- /3.1/docker-entrypoint.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # Uses ss-server as default. 4 | if [ "${1#-}" != "$1" ]; then 5 | set -- ss-server "$@" 6 | fi 7 | 8 | function print_usage { 9 | echo 10 | echo "Usage:" 11 | echo " ss-server [OPTIONS]" 12 | echo 13 | echo "Options:" 14 | echo " -p, --password string Password of your remote server" 15 | echo " -m, --encrypt-method string Encrypt method: table, rc4, rc4-md5, aes-128-cfb, aes-192-cfb," 16 | echo " aes-256-cfb, bf-cfb, camellia-128-cfb, camellia-192-cfb," 17 | echo " camellia-256-cfb, cast5-cfb, des-cfb, idea-cfb, rc2-cfb," 18 | echo " seed-cfb, salsa20, chacha20, aes-128-gcm, aes-192-gcm, aes-256-gcm," 19 | echo " chacha20-poly1305, chacha20-ietf-poly1305" 20 | echo " -t, --timeout int Socket timeout in seconds" 21 | echo " -u Enable UDP relay" 22 | echo " -U Enable UDP relay and disable TCP relay" 23 | echo " -v Verbose mode" 24 | echo " --acl string Path to ACL (Access Control List)" 25 | echo " --fast-open Enable TCP fast open, need Linux kernel > 3.7.0" 26 | echo " --mtu int MTU of your network interface" 27 | echo 28 | echo " -h, --help Print this message" 29 | echo 30 | } 31 | 32 | if [ "$1" != "ss-server" ]; then 33 | exec "$@" 34 | fi 35 | 36 | shift 37 | OPTIONS=`getopt -o p:m:t:od:uUvh --long password:,encrypt-method:,timeout:,onetime-auth,dns:,acl:,fast-open,mtu:,help -n shadowsocks -- "$@"` 38 | if [ $? -ne 0 ]; then 39 | print_usage 40 | exit 1 41 | fi 42 | 43 | SS_HOST="-s 0.0.0.0" 44 | SS_PORT="-p 8989" 45 | SS_USER="-a shadowsocks" 46 | 47 | eval set -- "$OPTIONS" 48 | while true; do 49 | case "$1" in 50 | -p|--password) SS_PASSWORD="-k $2"; shift 2;; 51 | -m|--encrypt-method) SS_ENCRYPT_METHOD="-m $2"; shift 2;; 52 | -t|--timeout) SS_TIMEOUT="-t $2"; shift 2;; 53 | -d|--dns) SS_DNS="-d $2"; shift 2;; 54 | -u) SS_UDP_RELAY="-u"; shift;; 55 | -U) SS_UDP_RELAY_ONLY="-U"; shift;; 56 | -v) SS_VERBOSE="-v"; shift;; 57 | --acl) SS_ACL="--acl $2"; shift 2;; 58 | --fast-open) SS_FAST_OPEN="--fast-open"; shift;; 59 | --mtu) SS_MTU="--mtu $2"; shift 2;; 60 | --) shift; break;; 61 | -h|--help) print_usage; exit 0;; 62 | 63 | *) 64 | echo "Unexpected argument: $1" 65 | print_usage 66 | exit 1;; 67 | esac 68 | done 69 | 70 | if [ -z "$SS_PASSWORD" ]; then 71 | SS_PASSWORD="$(pwgen -1 8)" 72 | echo "Generated password: $SS_PASSWORD" 73 | SS_PASSWORD="-k $SS_PASSWORD" 74 | fi 75 | 76 | ss-server $SS_HOST $SS_PORT $SS_USER $SS_PASSWORD $SS_ENCRYPT_METHOD $SS_TIMEOUT $SS_ONETIME_AUTH $SS_DNS $SS_UDP_RELAY $SS_UDP_RELAY_ONLY $SS_VERBOSE $SS_ACL $SS_FAST_OPEN $SS_MTU -------------------------------------------------------------------------------- /3.2/Dockerfile: -------------------------------------------------------------------------------- 1 | # Shadowsocks 2 | # Cogset Open Source Group 3 | 4 | FROM debian:jessie 5 | 6 | MAINTAINER Cogset 7 | 8 | RUN groupadd -r shadowsocks && useradd -r -g shadowsocks shadowsocks 9 | 10 | ENV SHADOWSOCKS_VERSION v3.2.3 11 | 12 | # Install 13 | RUN buildDeps="wget autoconf make g++ libssl-dev libpcre3-dev ca-certificates" \ 14 | && apt-get update \ 15 | && apt-get install -y --no-install-recommends pwgen build-essential libtool asciidoc xmlto $buildDeps \ 16 | && wget -O shadowsocks.tar.gz "https://github.com/shadowsocks/shadowsocks-libev/archive/$SHADOWSOCKS_VERSION.tar.gz" \ 17 | && mkdir -p /usr/src/shadowsocks \ 18 | && tar -xzf shadowsocks.tar.gz -C /usr/src/shadowsocks --strip-components=1 \ 19 | && rm shadowsocks.tar.gz \ 20 | && cd /usr/src/shadowsocks \ 21 | && ./configure \ 22 | && make \ 23 | && make install \ 24 | && cd / \ 25 | && rm -rf /usr/src/shadowsocks \ 26 | && apt-get purge -y --auto-remove $buildDeps \ 27 | && rm -rf /var/lib/apt/lists/* 28 | 29 | COPY docker-entrypoint.sh /usr/local/bin/ 30 | RUN chmod +x /usr/local/bin/docker-entrypoint.sh 31 | 32 | ENTRYPOINT ["docker-entrypoint.sh"] 33 | 34 | EXPOSE 8989 35 | 36 | CMD ["ss-server"] 37 | -------------------------------------------------------------------------------- /3.2/docker-entrypoint.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # Uses ss-server as default. 4 | if [ "${1#-}" != "$1" ]; then 5 | set -- ss-server "$@" 6 | fi 7 | 8 | function print_usage { 9 | echo 10 | echo "Usage:" 11 | echo " ss-server [OPTIONS]" 12 | echo 13 | echo "Options:" 14 | echo " -p, --password string Password of your remote server" 15 | echo " -m, --encrypt-method string Encrypt method: table, rc4, rc4-md5, aes-128-cfb, aes-192-cfb," 16 | echo " aes-256-cfb, bf-cfb, camellia-128-cfb, camellia-192-cfb," 17 | echo " camellia-256-cfb, cast5-cfb, des-cfb, idea-cfb, rc2-cfb," 18 | echo " seed-cfb, salsa20, chacha20, aes-128-gcm, aes-192-gcm, aes-256-gcm," 19 | echo " chacha20-poly1305, chacha20-ietf-poly1305" 20 | echo " -t, --timeout int Socket timeout in seconds" 21 | echo " -u Enable UDP relay" 22 | echo " -U Enable UDP relay and disable TCP relay" 23 | echo " -v Verbose mode" 24 | echo " --acl string Path to ACL (Access Control List)" 25 | echo " --fast-open Enable TCP fast open, need Linux kernel > 3.7.0" 26 | echo " --mtu int MTU of your network interface" 27 | echo 28 | echo " -h, --help Print this message" 29 | echo 30 | } 31 | 32 | if [ "$1" != "ss-server" ]; then 33 | exec "$@" 34 | fi 35 | 36 | shift 37 | OPTIONS=`getopt -o p:m:t:od:uUvh --long password:,encrypt-method:,timeout:,onetime-auth,dns:,acl:,fast-open,mtu:,help -n shadowsocks -- "$@"` 38 | if [ $? -ne 0 ]; then 39 | print_usage 40 | exit 1 41 | fi 42 | 43 | SS_HOST="-s 0.0.0.0" 44 | SS_PORT="-p 8989" 45 | SS_USER="-a shadowsocks" 46 | 47 | eval set -- "$OPTIONS" 48 | while true; do 49 | case "$1" in 50 | -p|--password) SS_PASSWORD="-k $2"; shift 2;; 51 | -m|--encrypt-method) SS_ENCRYPT_METHOD="-m $2"; shift 2;; 52 | -t|--timeout) SS_TIMEOUT="-t $2"; shift 2;; 53 | -d|--dns) SS_DNS="-d $2"; shift 2;; 54 | -u) SS_UDP_RELAY="-u"; shift;; 55 | -U) SS_UDP_RELAY_ONLY="-U"; shift;; 56 | -v) SS_VERBOSE="-v"; shift;; 57 | --acl) SS_ACL="--acl $2"; shift 2;; 58 | --fast-open) SS_FAST_OPEN="--fast-open"; shift;; 59 | --mtu) SS_MTU="--mtu $2"; shift 2;; 60 | --) shift; break;; 61 | -h|--help) print_usage; exit 0;; 62 | 63 | *) 64 | echo "Unexpected argument: $1" 65 | print_usage 66 | exit 1;; 67 | esac 68 | done 69 | 70 | if [ -z "$SS_PASSWORD" ]; then 71 | SS_PASSWORD="$(pwgen -1 8)" 72 | echo "Generated password: $SS_PASSWORD" 73 | SS_PASSWORD="-k $SS_PASSWORD" 74 | fi 75 | 76 | ss-server $SS_HOST $SS_PORT $SS_USER $SS_PASSWORD $SS_ENCRYPT_METHOD $SS_TIMEOUT $SS_ONETIME_AUTH $SS_DNS $SS_UDP_RELAY $SS_UDP_RELAY_ONLY $SS_VERBOSE $SS_ACL $SS_FAST_OPEN $SS_MTU -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) Cogset Open Source Group and contributors 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ## Shadowsocks in Docker 2 | [![build status badge](https://travis-ci.org/cogset/shadowsocks.svg)](https://travis-ci.org/cogset/shadowsocks) 3 | [![layers badge](https://images.microbadger.com/badges/image/cogset/shadowsocks.svg)](https://microbadger.com/images/cogset/shadowsocks) 4 | ### Supported tags and respective Dockerfile links 5 | 6 | + `3.1.3`, `3.1`, `latest` [(3.1/Dockerfile)](https://github.com/cogset/shadowsocks/blob/master/3.1/Dockerfile) 7 | + `3.2.3`, `3.2`, `latest` [(3.2/Dockerfile)](https://github.com/cogset/shadowsocks/blob/master/3.2/Dockerfile) 8 | 9 | ------ 10 | ### Software website 11 | + [Shadowsocks](https://shadowsocks.org) 12 | 13 | ------ 14 | ### Author 15 | + You Ming (youming@funcuter.org) 16 | 17 | ------ 18 | ### Usage 19 | 20 | ##### Run a Shadowsocks instance 21 | ``` 22 | $ docker run -d --name shadowsocks -p 8989:8989 cogset/shadowsocks:latest 23 | ``` 24 | The port of socks server is `8989`. 25 | 26 | ##### Set authorization 27 | You can use `-p` or `--password` to set authorization. 28 | ``` 29 | $ docker run -d --name shadowsocks -p 8989:8989 cogset/shadowsocks:latest -p 1234 30 | ``` 31 | If you start container without password, a password will be generated automatically. 32 | 33 | ##### Other options 34 | Use `-h` or `--help` for full usage. 35 | ``` 36 | $ docker run -t --name shadowsocks cogset/shadowsocks:latest -h 37 | ``` 38 | --------------------------------------------------------------------------------