Skip to content

Commit

Permalink
📝 Allow to set the PUID and PGID using docker #12596
Browse files Browse the repository at this point in the history
  • Loading branch information
88250 committed Sep 28, 2024
1 parent f0e0b98 commit 214b566
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 16 deletions.
19 changes: 10 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -179,8 +179,8 @@ The entry point is set when building the Docker image: `ENTRYPOINT ["/opt/siyuan

Use the following parameters when running the container with `docker run b3log/siyuan`:

- `--workspace`: Specifies the workspace folder path, mounted to the container via `-v` on the host
- `--accessAuthCode`: Specifies the access authorization code
* `--workspace`: Specifies the workspace folder path, mounted to the container via `-v` on the host
* `--accessAuthCode`: Specifies the access authorization code

More parameters can be found using `--help`. Here’s an example of a startup command with the new environment variables:

Expand All @@ -194,11 +194,11 @@ docker run -d \
--accessAuthCode=xxx
```

- `PUID`: Custom user ID (optional, defaults to `1000` if not provided)
- `PGID`: Custom group ID (optional, defaults to `1000` if not provided)
- `workspace_dir_host`: The workspace folder path on the host
- `workspace_dir_container`: The path of the workspace folder in the container, as specified in `--workspace`
- `accessAuthCode`: Access authorization code (please **be sure to modify**, otherwise anyone can access your data)
* `PUID`: Custom user ID (optional, defaults to `1000` if not provided)
* `PGID`: Custom group ID (optional, defaults to `1000` if not provided)
* `workspace_dir_host`: The workspace folder path on the host
* `workspace_dir_container`: The path of the workspace folder in the container, as specified in `--workspace`
* `accessAuthCode`: Access authorization code (please **be sure to modify**, otherwise anyone can access your data)

To simplify things, it is recommended to configure the workspace folder path to be consistent on the host and container, such as having both `workspace_dir_host` and `workspace_dir_container` configured as `/siyuan/workspace`. The corresponding startup command would be:

Expand Down Expand Up @@ -235,8 +235,9 @@ services:
```
In this setup:
- `PUID` and `PGID` are set dynamically and passed to the container.
- If these variables are not provided, the default `1000` will be used.
* `PUID` and `PGID` are set dynamically and passed to the container
* If these variables are not provided, the default `1000` will be used

By specifying `PUID` and `PGID` in the environment, you avoid the need to explicitly set the `user` directive (`user: '1000:1000'`) in the compose file. The container will dynamically adjust the user and group based on these environment variables at startup.
Expand Down
15 changes: 8 additions & 7 deletions README_zh_CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -178,9 +178,9 @@

#### 启动入口

入口点在构建 Docker 镜像时设置: `ENTRYPOINT ["/opt/siyuan/entrypoint.sh"]`。该脚本允许更改将在容器内运行的用户的 `PUID``PGID`。这对于解决从主机挂载目录时的权限问题尤为重要。`PUID``PGID` 可以作为环境变量传递,这样在访问主机挂载的目录时就能更容易地确保正确的权限。
入口点在构建 Docker 镜像时设置:`ENTRYPOINT ["/opt/siyuan/entrypoint.sh"]`。该脚本允许更改将在容器内运行的用户的 `PUID``PGID`。这对于解决从主机挂载目录时的权限问题尤为重要。`PUID``PGID` 可以作为环境变量传递,这样在访问主机挂载的目录时就能更容易地确保正确的权限。

使用 `docker run b3log/siyuan` 运行容器时,请使用以下参数
使用 `docker run b3log/siyuan` 运行容器时,请带入以下参数

* `--workspace`:指定工作空间文件夹路径,在宿主机上通过 `-v` 挂载到容器中
* `--accessAuthCode`:指定访问授权码
Expand All @@ -197,8 +197,8 @@ docker run -d \
--accessAuthCode=xxx
```

* `PUID`: 自定义用户 ID(可选,如果未提供,默认为 `1000)
* `PGID`: 自定义组 ID(可选,如果未提供,默认为 `1000)
* `PUID`: 自定义用户 ID(可选,如果未提供,默认为 `1000`
* `PGID`: 自定义组 ID(可选,如果未提供,默认为 `1000`
* `workspace_dir_host`:宿主机上的工作空间文件夹路径
* `workspace_dir_container`:容器内工作空间文件夹路径,和后面 `--workspace` 指定成一样的
* `accessAuthCode`:访问授权码,请**务必修改**,否则任何人都可以读写你的数据
Expand All @@ -215,7 +215,7 @@ docker run -d \
--accessAuthCode=xxx
```

使用 Docker Compose 部署请参考下面的示例:
#### Docker Compose

对于使用 Docker Compose 运行思源的用户,可以通过环境变量 `PUID``PGID` 来自定义用户和组的 ID。下面是一个 Docker Compose 配置示例:

Expand All @@ -238,8 +238,9 @@ services:
```
在此设置中:
- PUID “和 ”PGID "是动态设置并传递给容器的。
- 如果没有提供这些变量,将使用默认的 `1000`。
* PUID “和 ”PGID "是动态设置并传递给容器的
* 如果没有提供这些变量,将使用默认的 `1000`

在环境中指定 `PUID` 和 `PGID` 后,就无需在组成文件中明确设置 `user` 指令(`user: '1000:1000'`)。容器将在启动时根据这些环境变量动态调整用户和组。
Expand Down

0 comments on commit 214b566

Please sign in to comment.