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.

126 lines
4.5 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 --fast-open -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 other customizations
  43. Besides `PASSWORD`, the image also defines the following environment variables that you can customize:
  44. * `SERVER_ADDR`: the IP/domain to bind to, defaults to `0.0.0.0`
  45. * `SERVER_ADDR_IPV6`: the IPv6 address to bind to, defaults to `::0`
  46. * `METHOD`: encryption method to use, defaults to `aes-256-gcm`
  47. * `TIMEOUT`: defaults to `300`
  48. * `DNS_ADDRS`: DNS servers to redirect NS lookup requests to, defaults to `8.8.8.8,8.8.4.4`
  49. Additional arguments supported by `ss-server` can be passed with the environment variable `ARGS`, for instance to start in verbose mode:
  50. ```bash
  51. $ docker run -e ARGS=-v -p 8388:8388 -p 8388:8388/udp -d --restart always shadowsocks/shadowsocks-libev:latest
  52. ```
  53. ## Use docker-compose to manage (optional)
  54. It is very handy to use [docker-compose][7] to manage docker containers.
  55. You can download the binary at <https://github.com/docker/compose/releases>.
  56. This is a sample `docker-compose.yml` file.
  57. ```yaml
  58. shadowsocks:
  59. image: shadowsocks/shadowsocks-libev
  60. ports:
  61. - "8388:8388"
  62. environment:
  63. - METHOD=aes-256-gcm
  64. - PASSWORD=9MLSpPmNt
  65. restart: always
  66. ```
  67. It is highly recommended that you setup a directory tree to make things easy to manage.
  68. ```bash
  69. $ mkdir -p ~/fig/shadowsocks/
  70. $ cd ~/fig/shadowsocks/
  71. $ curl -sSLO https://github.com/shadowsocks/shadowsocks-libev/raw/master/docker/alpine/docker-compose.yml
  72. $ docker-compose up -d
  73. $ docker-compose ps
  74. ```
  75. ## Finish
  76. At last, download shadowsocks client [here][8].
  77. Don't forget to share internet with your friends.
  78. ```yaml
  79. {
  80. "server": "your-vps-ip",
  81. "server_port": 8388,
  82. "local_address": "0.0.0.0",
  83. "local_port": 1080,
  84. "password": "9MLSpPmNt",
  85. "timeout": 600,
  86. "method": "aes-256-gcm"
  87. }
  88. ```
  89. [1]: https://github.com/shadowsocks/shadowsocks-libev
  90. [2]: https://shadowsocks.org/en/index.html
  91. [6]: https://duckduckgo.com/?q=password+12&t=ffsb&ia=answer
  92. [7]: https://github.com/docker/compose
  93. [8]: https://shadowsocks.org/en/download/clients.html
  94. [9]: https://docs.docker.com/
  95. [10]: https://www.digitalocean.com/products/linux-distribution/coreos/
  96. [11]: https://cloud.google.com/container-optimized-os/
  97. [12]: https://docs.docker.com/install/
  98. [13]: https://hub.docker.com/r/shadowsocks/shadowsocks-libev/tags/