From 0eb640252cd2349633cb7b16d91c73d1940c2477 Mon Sep 17 00:00:00 2001 From: mritd Date: Sat, 18 Sep 2021 17:05:30 +0800 Subject: [PATCH 1/2] docs(docker): add docker docs add docker docs Signed-off-by: mritd --- Docker.md | 64 +++++++++++++++++++++++++++++++++++++++++++++ Docker.zh.md | 60 ++++++++++++++++++++++++++++++++++++++++++ docker-compose.yaml | 10 +++++++ 3 files changed, 134 insertions(+) create mode 100644 Docker.md create mode 100644 Docker.zh.md create mode 100644 docker-compose.yaml diff --git a/Docker.md b/Docker.md new file mode 100644 index 0000000..0f3dfbe --- /dev/null +++ b/Docker.md @@ -0,0 +1,64 @@ +## About Dockerfile + +The hysteria docker image is based on the **alpine** system. This means that +**some glibc calls may not work if you run programs that depend on glibc in a container.** + +By default, **bash** is installed in the docker container for debugging, **tzdata** is used to +provide container time zone configuration, and **ca-certificates** is used to ensure the +trust of the ssl certificate chain; in addition, the docker container does not contain +any tools other than the alpine standard system. + +The hysteria binary is installed in `/usr/local/bin/hysteria`, and the **ENTRYPOINT** +of the docker container is set to **execute the `hysteria` command**; this means that +the `hysteria` command is always the first command. + +## How to use docker image? + +### For standard docker users + +You can mount the configuration file to any location of the docker container and use it. + +In the following commands, we assume that the **`/root/hysteria.json`** configuration +file is mounted to **`/etc/hysteria.json`**: + +```sh +# Please replace `/root/hysteria.json` with the actual configuration file location +docker run -dt --name hysteria \ + -v /root/hysteria.json:/etc/hysteria.json \ + tobyxdd/hysteria -config /etc/hysteria.json server +``` + +### For docker-compose users + +First, you need to create a directory with any name, and then copy [docker-compise.yaml](https://raw.githubusercontent.com/HyNetwork/hysteria/master/docker-compose.yaml) to +that directory. Finally, create your configuration file and start it. + +```sh +# Create dir +mkdir hysteria && cd hysteria + +# Download the docker-compose example config +wget https://raw.githubusercontent.com/HyNetwork/hysteria/master/docker-compose.yaml + +# Create your config +cat < hysteria.json +{ + "listen": ":36712", + "acme": { + "domains": [ + "your.domain.com" + ], + "email": "hacker@gmail.com" + }, + "obfs": "fuck me till the daylight", + "up_mbps": 100, + "down_mbps": 100 +} +EOF + +# Start container +docker-compose up -d +``` + + + diff --git a/Docker.zh.md b/Docker.zh.md new file mode 100644 index 0000000..7ae63c6 --- /dev/null +++ b/Docker.zh.md @@ -0,0 +1,60 @@ +## 关于 Dockerfile + +hysteria 的 docker 镜像基于 **alpine** 系统,这意味着如果您在容器里运行一些依赖于 glibc +的自定义程序可能会失败。 + +默认情况下容器内安装了 **`bash`** 用于调试目的,安装的 **`tzdata`** 用于提供容器的时区信息; +为了保证 ACME 等连其他网站时 SSL 证书信任还安装了 **`ca-certificates`**;除此之外容器内不包含 +任何非标准 alpine 系统的其他工具。 + +hysteria 二进制可执行文件默认被安装到 `/usr/local/bin/hysteria`,同时容器的 **ENTRYPOINT** +被设置为**执行 `hysteria` 命令**;这意味着在不进行覆盖的情况下容器启动后首先将执行 `hysteria` +命令。 + +## 如何使用本镜像? + +### 标准 Docker 用户 + +您可以将配置文件挂载到容器内的任何位置然后使用它。 + +在下面的命令中我们假设将 **`/root/hysteria.json`** 配置文件挂载为容器内的 **`/etc/hysteria.json`** 文件。 + +```sh +# Please replace `/root/hysteria.json` with the actual configuration file location +docker run -dt --name hysteria \ + -v /root/hysteria.json:/etc/hysteria.json \ + tobyxdd/hysteria -config /etc/hysteria.json server +``` + +### Docker Compose 用户 + +首先您需要创建一个任意名称的目录,然后将项目内的 [docker-compise.yaml](https://raw.githubusercontent.com/HyNetwork/hysteria/master/docker-compose.yaml) 文件复制到该目录; +最后创建自己的配置文件并启动即可。 + +```sh +# Create dir +mkdir hysteria && cd hysteria + +# Download the docker-compose example config +wget https://raw.githubusercontent.com/HyNetwork/hysteria/master/docker-compose.yaml + +# Create your config +cat < hysteria.json +{ + "listen": ":36712", + "acme": { + "domains": [ + "your.domain.com" + ], + "email": "hacker@gmail.com" + }, + "obfs": "fuck me till the daylight", + "up_mbps": 100, + "down_mbps": 100 +} +EOF + +# Start container +docker-compose up -d +``` + diff --git a/docker-compose.yaml b/docker-compose.yaml new file mode 100644 index 0000000..964ccd8 --- /dev/null +++ b/docker-compose.yaml @@ -0,0 +1,10 @@ +version: '3.8' +services: + hysteria: + image: tobyxdd/hysteria + container_name: hysteria + restart: always + network_mode: "host" + volumes: + - ./hysteria.json:/etc/hysteria.json + command: ["-config","/etc/hysteria.json","server"] From 700f101aa169a977da586dec52002151f603dcb4 Mon Sep 17 00:00:00 2001 From: mritd Date: Sat, 18 Sep 2021 17:35:49 +0800 Subject: [PATCH 2/2] docs(README): add docker doc link add docker doc link Signed-off-by: mritd --- README.md | 4 ++-- README.zh.md | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 7f735af..4b70dc2 100644 --- a/README.md +++ b/README.md @@ -34,7 +34,7 @@ currently has the following features: (still growing!) - Linux builds are available as `hysteria` (with tun support) and `hysteria-notun` (without tun support). Builds without tun support are statically linked and do not depend on glibc. **If you use a non-standard distribution that can't run `hysteria` properly, try `hysteria-notun` instead.** -- Pull the image from Docker Hub: https://hub.docker.com/r/tobyxdd/hysteria +- Use Docker or Docker Compose: https://github.com/HyNetwork/hysteria/blob/master/Docker.md - Use our Arch Linux AUR: https://aur.archlinux.org/packages/hysteria/ - Build from source with `go build ./cmd` @@ -356,4 +356,4 @@ To change the logging level, use `LOGGING_LEVEL` environment variable. The avail To print JSON instead, set `LOGGING_FORMATTER` to `json` -To change the logging timestamp format, set `LOGGING_TIMESTAMP_FORMAT` \ No newline at end of file +To change the logging timestamp format, set `LOGGING_TIMESTAMP_FORMAT` diff --git a/README.zh.md b/README.zh.md index 203c5e4..fda6856 100644 --- a/README.zh.md +++ b/README.zh.md @@ -30,7 +30,7 @@ Hysteria 是一个功能丰富的,专为恶劣网络环境进行优化的网 - 从 https://github.com/tobyxdd/hysteria/releases 下载编译好的版本 - Linux 分为 `hysteria` (带有 tun 支持) 和 `hysteria-notun` (无 tun 支持) 两个版本。无 tun 支持的版本是静态链接,不依赖系统 glibc 的。**如果你使用了非标准 Linux 发行版,无法正常执行 `hysteria`,可尝试 `hysteria-notun`** -- Docker 镜像: https://hub.docker.com/r/tobyxdd/hysteria +- 使用 Docker 或 Docker Compose: https://github.com/HyNetwork/hysteria/blob/master/Docker.zh.md - 使用 Arch Linux AUR: https://aur.archlinux.org/packages/hysteria/ - 自己用 `go build ./cmd` 从源码编译 @@ -337,4 +337,4 @@ Hysteria 服务端与客户端默认的 receive window 大小是 64 MB。如果 如果需要输出 JSON 可以把 `LOGGING_FORMATTER` 设置为 `json` -如果需要修改日志时间戳格式可以使用 `LOGGING_TIMESTAMP_FORMAT` \ No newline at end of file +如果需要修改日志时间戳格式可以使用 `LOGGING_TIMESTAMP_FORMAT`