You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

153 lines
5.6 KiB

  1. # Shadowsocks-libev Docker Image
  2. [shadowsocks-libev][1] is a lightweight secured socks5 proxy for embedded
  3. devices and low end boxes. It is a port of [shadowsocks][2] created by
  4. @clowwindy maintained by @madeye and @linusyang.
  5. Docker images are built for quick deployment in various computing cloud providers. For more information on docker and containerization technologies, refer to [official document][9].
  6. ## Prepare the host
  7. Many cloud providers offer docker-ready environments, for instance the [CoreOS Droplet in DigitalOcean][10] or the [Container-Optimized OS in Google Cloud][11].
  8. If you need to install docker yourself, follow the [official installation guide][12].
  9. ## Pull the image
  10. ```bash
  11. $ docker pull shadowsocks/shadowsocks-libev
  12. ```
  13. This pulls the latest release of shadowsocks-libev.
  14. You can also choose to pull a previous release or to try the bleeding edge build:
  15. ```bash
  16. $ docker pull shadowsocks/shadowsocks-libev:<tag>
  17. $ docker pull shadowsocks/shadowsocks-libev:edge
  18. ```
  19. > A list of supported tags can be found at [Docker Hub][13].
  20. ## Start a container
  21. ```bash
  22. $ docker run -p 8388:8388 -p 8388:8388/udp -d --restart always shadowsocks/shadowsocks-libev:latest
  23. ```
  24. This starts a container of the latest release with all the default settings, which is equivalent to
  25. ```bash
  26. $ ss-server -s 0.0.0.0 -p 8388 -k "$(hostname)" -m aes-256-gcm -t 300 -d "8.8.8.8,8.8.4.4" -u
  27. ```
  28. > **Note**: It's the hostname in the container that is used as the password, not that of the host.
  29. ### With custom port
  30. In most cases you'll want to change a thing or two, for instance the port which the server listens on. This is done by changing the `-p` arguments.
  31. Here's an example to start a container that listens on `28388` (both TCP and UDP):
  32. ```bash
  33. $ docker run -p 28388:8388 -p 28388:8388/udp -d --restart always shadowsocks/shadowsocks-libev
  34. ```
  35. ### With custom password
  36. Another thing you may want to change is the password. To change that, you can pass your own password as an environment variable when starting the container.
  37. Here's an example to start a container with `9MLSpPmNt` as the password:
  38. ```bash
  39. $ docker run -e PASSWORD=9MLSpPmNt -p 8388:8388 -p 8388:8388/udp -d --restart always shadowsocks/shadowsocks-libev
  40. ```
  41. > :warning: Click [here][6] to generate a strong password to protect your server.
  42. ### With password as a mounted file or a Docker secret (swarm only)
  43. Instead of hardcoding a password to the docker-compose file or `docker run` command, you can mount in a file that contains the password. To do so, pass the path that you mounted to the container as the `PASSWORD_FILE` environment variable.
  44. If you are running Docker Swarm, you can also utilize Docker secrets. To do so, pass the name of the secret as the `PASSWORD_SECRET` environment variable. If you specify both `PASSWORD_FILE` and `PASSWORD_SECRET`, the latter will take effect.
  45. This is a sample `docker-compose.yml` file that uses the external Docker secret named `shadowsocks` as the password.
  46. ```yaml
  47. shadowsocks:
  48. image: shadowsocks/shadowsocks-libev
  49. ports:
  50. - "8388:8388"
  51. environment:
  52. - METHOD=aes-256-gcm
  53. - PASSWORD_SECRET=shadowsocks
  54. secrets:
  55. - shadowsocks
  56. ```
  57. This is a sample `docker service create` command that uses the external Docker secret named `shadowsocks` as the password.
  58. ```bash
  59. docker service create -e PASSWORD_SECRET=shadowsocks -p 8388:8388 -p 8388:8388/udp --secret shadowsocks shadowsocks/shadowsocks-libev
  60. ```
  61. ### With other customizations
  62. Besides `PASSWORD`, the image also defines the following environment variables that you can customize:
  63. * `SERVER_ADDR`: the IP/domain to bind to, defaults to `0.0.0.0`
  64. * `SERVER_ADDR_IPV6`: the IPv6 address to bind to, defaults to `::0`
  65. * `METHOD`: encryption method to use, defaults to `aes-256-gcm`
  66. * `TIMEOUT`: defaults to `300`
  67. * `DNS_ADDRS`: DNS servers to redirect NS lookup requests to, defaults to `8.8.8.8,8.8.4.4`
  68. * `TZ`: Timezone, defaults to `UTC`
  69. Additional arguments supported by `ss-server` can be passed with the environment variable `ARGS`, for instance to start in verbose mode:
  70. ```bash
  71. $ docker run -e ARGS=-v -p 8388:8388 -p 8388:8388/udp -d --restart always shadowsocks/shadowsocks-libev:latest
  72. ```
  73. ## Use docker-compose to manage (optional)
  74. It is very handy to use [docker-compose][7] to manage docker containers.
  75. You can download the binary at <https://github.com/docker/compose/releases>.
  76. This is a sample `docker-compose.yml` file.
  77. ```yaml
  78. shadowsocks:
  79. image: shadowsocks/shadowsocks-libev
  80. ports:
  81. - "8388:8388"
  82. environment:
  83. - METHOD=aes-256-gcm
  84. - PASSWORD=9MLSpPmNt
  85. restart: always
  86. ```
  87. It is highly recommended that you setup a directory tree to make things easy to manage.
  88. ```bash
  89. $ mkdir -p ~/fig/shadowsocks/
  90. $ cd ~/fig/shadowsocks/
  91. $ curl -sSLO https://github.com/shadowsocks/shadowsocks-libev/raw/master/docker/alpine/docker-compose.yml
  92. $ docker-compose up -d
  93. $ docker-compose ps
  94. ```
  95. ## Finish
  96. At last, download shadowsocks client [here][8].
  97. Don't forget to share internet with your friends.
  98. ```yaml
  99. {
  100. "server": "your-vps-ip",
  101. "server_port": 8388,
  102. "local_address": "0.0.0.0",
  103. "local_port": 1080,
  104. "password": "9MLSpPmNt",
  105. "timeout": 600,
  106. "method": "aes-256-gcm"
  107. }
  108. ```
  109. [1]: https://github.com/shadowsocks/shadowsocks-libev
  110. [2]: https://shadowsocks.org/en/index.html
  111. [6]: https://duckduckgo.com/?q=password+12&t=ffsb&ia=answer
  112. [7]: https://github.com/docker/compose
  113. [8]: https://shadowsocks.org/en/download/clients.html
  114. [9]: https://docs.docker.com/
  115. [10]: https://www.digitalocean.com/products/linux-distribution/coreos/
  116. [11]: https://cloud.google.com/container-optimized-os/
  117. [12]: https://docs.docker.com/install/
  118. [13]: https://hub.docker.com/r/shadowsocks/shadowsocks-libev/tags/