-
Notifications
You must be signed in to change notification settings - Fork 28
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
docs(docker): add running as diffrent user site (#150)
- Loading branch information
1 parent
25a0ac1
commit 50e9d9a
Showing
2 changed files
with
105 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
--- | ||
title: Running as a different user | ||
tags: | ||
- Configuration | ||
- Docker | ||
- Advanced | ||
- PGID | ||
- PUID | ||
--- | ||
|
||
By default the container is running with user `root` and group `root`. | ||
You can change the user and group by using the `PUID` and `PGID` environment variables. | ||
Important to note is, that you'll also need to change the permissions for the mounted directories accordingly. | ||
|
||
:::info | ||
When starting up an updated version of the container it will have about **10 seconds longer to start** as it has to change the permissions of the app directories | ||
::: | ||
|
||
## Without mounted Docker socket | ||
|
||
To run your container as a different user, you can use the `PUID` and `PGID` environment variables: | ||
|
||
```yml title="docker-compose.yml" | ||
#---------------------------------------------------------------------# | ||
# Homarr - A simple, yet powerful dashboard for your server. # | ||
#---------------------------------------------------------------------# | ||
services: | ||
homarr: | ||
container_name: homarr | ||
image: ghcr.io/homarr-labs/homarr:latest | ||
restart: unless-stopped | ||
volumes: | ||
- ./homarr/appdata:/appdata | ||
environment: | ||
- SECRET_ENCRYPTION_KEY=your_64_character_hex_string # <--- can be generated with `openssl rand -hex 32` | ||
- PUID=1000 | ||
- PGID=1000 | ||
ports: | ||
- '7575:7575' | ||
``` | ||
After that you'll need to create the appdata directory and set the correct permissions: | ||
```bash title="On host" | ||
mkdir -p ./homarr/appdata | ||
chown -R 1000:1000 ./homarr/appdata | ||
``` | ||
|
||
## With mounted Docker socket | ||
|
||
If you want to use the Docker integration, you'll need to set the correct permissions for the Docker socket as well, most of the times it will have the owner group set to docker group. | ||
In any way, it is recommended to create this group and set it's permissions to it, if it doesn't exist yet: | ||
|
||
```bash title="On host" | ||
groupadd -g 999 docker | ||
``` | ||
|
||
Then you can set the permissions for the Docker socket: | ||
|
||
```bash title="On host" | ||
chown root:docker /var/run/docker.sock | ||
``` | ||
|
||
After that you can set the `PUID` and `PGID` environment variables in your `docker-compose.yml` file: | ||
|
||
```yml title="docker-compose.yml" | ||
#---------------------------------------------------------------------# | ||
# Homarr - A simple, yet powerful dashboard for your server. # | ||
#---------------------------------------------------------------------# | ||
services: | ||
homarr: | ||
container_name: homarr | ||
image: ghcr.io/homarr-labs/homarr:latest | ||
restart: unless-stopped | ||
volumes: | ||
- /var/run/docker.sock:/var/run/docker.sock | ||
- ./homarr/appdata:/appdata | ||
environment: | ||
- SECRET_ENCRYPTION_KEY=your_64_character_hex_string # <--- can be generated with `openssl rand -hex 32` | ||
- PUID=1000 | ||
- PGID=999 | ||
ports: | ||
- '7575:7575' | ||
``` | ||
And set the permissions for the mounted directories: | ||
```bash title="On host" | ||
mkdir -p ./homarr/appdata | ||
chown -R 1000:999 ./homarr/appdata | ||
``` | ||
|
||
Important here is that the group ID is set to `999` as we created the `docker` group with this ID. |