Skip to content

Commit

Permalink
docs(docker): add running as diffrent user site (#150)
Browse files Browse the repository at this point in the history
  • Loading branch information
Meierschlumpf authored Dec 31, 2024
1 parent 25a0ac1 commit 50e9d9a
Show file tree
Hide file tree
Showing 2 changed files with 105 additions and 0 deletions.
12 changes: 12 additions & 0 deletions docs/advanced/environment-variables/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,18 @@ Homarr offers a Docker Container, which can be run on any compatible system, suc

Homarr offers a few environment variables, which can be used to configure the container.

## General

:::warning
Using the `PUID` and `PGID` will require you to set the correct permissions on the mounted volumes and if used the docker socket. See more in the [Running as a different user](/docs/advanced/running-as-different-user) documentation.
:::

| Environment Variable | Description | Possible values | Default |
| ------------------------ | ----------- | --------------- | ------- |
| ``PUID`` | User ID to run the container as | Any valid user ID | ``0`` |
| ``PGID`` | Group ID to run the container as | Any valid group ID | ``0`` |


## Authentication

See [Single Sign-On](/docs/advanced/single-sign-on) for more informations.
Expand Down
93 changes: 93 additions & 0 deletions docs/advanced/running-as-different-user/index.mdx
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.

0 comments on commit 50e9d9a

Please sign in to comment.