Merge pull request #134 from mritd/master

docs(docker): add docker docs
This commit is contained in:
Toby 2021-09-18 02:38:59 -07:00 committed by GitHub
commit 70028c2fa5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 138 additions and 4 deletions

64
Docker.md Normal file
View File

@ -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 <<EOF > 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
```

60
Docker.zh.md Normal file
View File

@ -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 <<EOF > 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
```

View File

@ -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`
To change the logging timestamp format, set `LOGGING_TIMESTAMP_FORMAT`

View File

@ -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`
如果需要修改日志时间戳格式可以使用 `LOGGING_TIMESTAMP_FORMAT`

10
docker-compose.yaml Normal file
View File

@ -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"]