You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+52-20
Original file line number
Diff line number
Diff line change
@@ -175,49 +175,80 @@ The overall program is located under `/opt/siyuan/`, which is basically the stru
175
175
176
176
#### Entrypoint
177
177
178
-
The entry point is set when building the Docker image: `ENTRYPOINT ["/opt/siyuan/kernel" ]`, use `docker run b3log/siyuan` with parameters to start:
178
+
The entry point is set when building the Docker image: `ENTRYPOINT ["/opt/siyuan/entrypoint.sh"]`. This script allows changing the `PUID` and `PGID` of the user that will run inside the container. This is especially relevant to solve permission issues when mounting directories from the host. The `PUID` (User ID) and `PGID` (Group ID) can be passed as environment variables, making it easier to ensure correct permissions when accessing host-mounted directories.
179
179
180
-
*`--workspace`: Specifies the workspace folder path, mounted to the container via `-v` on the host
181
-
*`--accessAuthCode`: Specifies the access authorization code
180
+
Use the following parameters when running the container with `docker run b3log/siyuan`:
182
181
183
-
More parameters can refer to `--help`. The following is an example of a startup command:
182
+
-`--workspace`: Specifies the workspace folder path, mounted to the container via `-v` on the host
183
+
-`--accessAuthCode`: Specifies the access authorization code
184
184
185
-
```
186
-
docker run -d -v workspace_dir_host:workspace_dir_container -p 6806:6806 b3log/siyuan --workspace=workspace_dir_container --accessAuthCode=xxx
187
-
```
188
-
189
-
*`workspace_dir_host`: The workspace folder path on the host
190
-
*`workspace_dir_container`: The path of the workspace folder in the container, which is the same as specified in `--workspace`
191
-
*`accessAuthCode`: Access authorization code, please **be sure to modify**, otherwise anyone can read and write your data
192
-
193
-
To simplify, it is recommended to configure the workspace folder path to be consistent on the host and container, such as: `workspace_dir_host` and `workspace_dir_container` are configured as `/siyuan/workspace`, the corresponding startup commands is:
185
+
More parameters can be found using `--help`. Here’s an example of a startup command with the new environment variables:
-`PUID`: Custom user ID (optional, defaults to `1000` if not provided)
198
+
-`PGID`: Custom group ID (optional, defaults to `1000` if not provided)
199
+
-`workspace_dir_host`: The workspace folder path on the host
200
+
-`workspace_dir_container`: The path of the workspace folder in the container, as specified in `--workspace`
201
+
-`accessAuthCode`: Access authorization code (please **be sure to modify**, otherwise anyone can access your data)
202
+
203
+
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:
204
+
205
+
```bash
206
+
docker run -d \
207
+
-v /siyuan/workspace:/siyuan/workspace \
208
+
-p 6806:6806 \
209
+
-e PUID=1001 -e PGID=1002 \
210
+
b3log/siyuan \
211
+
--workspace=/siyuan/workspace/ \
212
+
--accessAuthCode=xxx
197
213
```
198
214
199
-
Alternatively, see below for an example Docker Compose file:
215
+
#### Docker Compose
200
216
201
-
```
217
+
For users running Siyuan with Docker Compose, the environment variables `PUID` and `PGID` can be passed to customize the user and group IDs. Here's an example of a Docker Compose configuration:
# A list of time zone identifiers can be found at https://en.wikipedia.org/wiki/List_of_tz_database_time_zones
215
-
- TZ=${TimeZone}
232
+
- TZ=${YOUR_TIME_ZONE}
233
+
- PUID=${YOUR_USER_PUID} # Customize user ID
234
+
- PGID=${YOUR_USER_PGID} # Customize group ID
216
235
```
217
236
218
-
#### User permissions
237
+
In this setup:
238
+
- `PUID` and `PGID` are set dynamically and passed to the container.
239
+
- If these variables are not provided, the default `1000` will be used.
240
+
241
+
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.
242
+
243
+
#### User Permissions
244
+
245
+
In the image, the `entrypoint.sh` script ensures the creation of the `siyuan` user and group with the specified `PUID` and `PGID`. Therefore, when the host creates a workspace folder, pay attention to setting the user and group ownership of the folder to match the `PUID` and `PGID` you plan to use. For example:
246
+
247
+
```bash
248
+
chown -R 1001:1002 /siyuan/workspace
249
+
```
219
250
220
-
In the image, the normal user `siyuan` (uid 1000/gid 1000) created by default is used to start the kernel process. Therefore, when the host creates a workspace folder, please pay attention to setting the user group of the folder: `chown -R 1000:1000 /siyuan/workspace`. The parameter `-u 1000:1000` is required when starting the container.
251
+
If you use custom `PUID` and `PGID` values, the entrypoint script will ensure that the correct user and group are created inside the container, and ownership of mounted volumes will be adjusted accordingly. There’s no need to manually pass `-u` in `docker run` or `docker-compose` as the environment variables will handle the customization.
221
252
222
253
#### Hidden port
223
254
@@ -229,6 +260,7 @@ Use NGINX reverse proxy to hide port 6806, please note:
229
260
230
261
* Be sure to confirm the correctness of the mounted volume, otherwise the data will be lost after the container is deleted
231
262
* Do not use URL rewriting for redirection, otherwise there may be problems with authentication, it is recommended to configure a reverse proxy
263
+
* If you encounter permission issues, verify that the `PUID` and `PGID` environment variables match the ownership of the mounted directories on your host system
0 commit comments