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
If you want to use Gowebdav with Docker under a non-root user, you can follow these steps.
3
+
If you wish to run Gowebdav in Docker under a non-root user environment, please follow the steps below.
4
4
5
5
## Steps
6
6
7
-
Using Docker Compose as an example, let's say you want to share `./data/dir1` and `./data/dir2` directories. First, prepare a `docker-compose.yml` file:
7
+
Taking Docker Compose as an example, suppose you want to share two directories: `./data/dir1` and `./data/dir2`. First, prepare your directories:
8
+
9
+
```bash
10
+
mkdir -p ./data # This is just an example; you can create directories in any way you prefer
user: "nonroot"# Specify the user inside the container as nonroot
21
-
```
22
-
23
-
Next, create the directories and set the permissions to 777:
24
-
25
-
```bash
26
-
mkdir -p ./data/dir1 ./data/dir2
27
-
chmod 777 ./data/dir1 ./data/dir2
32
+
user: "1000:1000"# Replace with the correct UID and GID to ensure execution under the proper user
28
33
```
29
34
30
35
Finally, start the container:
@@ -35,10 +40,6 @@ docker compose up -d
35
40
36
41
## Notes
37
42
38
-
`117503445/go_webdav` is based on [gcr.io/distroless/static-debian12](https://github.com/GoogleContainerTools/distroless). The `nonroot` user inside the image is a non-root user with a UID of 65532 and has write permissions to the `/home/nonroot` directory.
39
-
40
-
- If you do not create the `data` directory in advance, it will be automatically created when the container starts. However, this will be done by the Docker Daemon with root privileges, which may lead to permission issues.
41
-
- If you do not create the `dir1` and `dir2` directories in advance, they will be created by `GoWebdav` when the container starts. Since these directories will belong to the `nonroot` user, external regular users will not be able to write to them.
42
-
- If you do not set the permissions to 777 in advance, the `nonroot` user in `GoWebdav` will not be able to write to these directories.
43
-
44
-
In the scenarios described above, both inside and outside the container are regular users. If you only require the container to run as a regular user and the host to run as root, or vice versa, the setup might be simpler.
43
+
Docker supports specifying a user via the `--user "UID:GID"` option, allowing you to run containers as a non-root user.
44
+
However, you must create the `data` directory in advance to prevent the Docker daemon from creating it with root permissions, which could lead to permission issues.
45
+
In the scenario above, both inside and outside the container use a regular (non-root) user. If you only require the container to run as a regular user while the host uses root (or vice versa), the setup might be simpler.
0 commit comments