Skip to content

feat: improve security - configure container uid and gid - #157

Merged
micbar merged 1 commit into
opencloud-eu:mainfrom
chillymattster:configure_uid_gid
Nov 25, 2025
Merged

micbar merged 1 commit into
opencloud-eu:mainfrom
chillymattster:configure_uid_gid

Conversation

@chillymattster

@chillymattster chillymattster commented Nov 14, 2025 •

Copy link
Copy Markdown
Contributor

Hi!

I had difficulties to achieve strict data access separation on a multi purpose server.

This is caused by not being able to change UID and GID of the users used in the containers. Using 1000:1000 as the default is quite common for a lot of containers on e.g. docker hub. On the host, I need to provide access for user 1000 to directories that are mounted into containers as volumes. From a security perspective, I don't want different containers belonging to completely separated apps or services in principle having access to data or config directories of each other but I'm forced to do so if I'm not able to change the users used in the containers. This is independent of using docker daemon default configuration and still stays the same when utilizing user namespace because the same UID in containers gets translated to the same (transformed) UID in the host in both scenarios which prevents being able to define fine granular access rights and access separation for different containers and applications.

Ideally, I want to have a strict separation of access to application data for each application. For Opencloud it would even be better to have separate access rights for Opencloud and Traefik container because Opencloud container needs access to data but not e.g. the private key from the domain certificate or docker.sock whereas Traefik only needs access to docker.sock, the certificate and some configuration but not the data stored by Opencloud.

In addition, Traefik runs in privileged mode, so using root inside the container which is not best practice from a security perspective. Currently I don't have a chance to configure Traefik to run in non-privileged mode and therfore I'm not able to follow best practice and security recommendations.

This PR introduces two variables OC_CONTAINER_UID_GID and TRAEFIK_CONTAINER_UID_GID. They can be used to alter the UID and GID for Opencloud and related containers on one hand and Traefik on the other hand. Those two variables offer freedom of choice to implement high security standards by separating data access, running Traefik in non-privileged mode or use Opencloud the same as before if security doesn't concern me a lot.
If those variables are not used, the defaults correspond to the UID and GID used up to now silently.

I would very much appreciate having the option to increase the security of my deployment. This PR is one way to do it, there might also be other ways of implementing it. If you feel this is not the way to do it, please feel free to let me know and deny this PR and propose a different way but as said, in general it would be very beneficial to offer increased security options.

Any questions and other thoughts are very welcome from my side as well 🙂

Cheers

Comment thread weboffice/collabora.yml

collaboration:
image: ${OC_DOCKER_IMAGE:-opencloudeu/opencloud-rolling}:${OC_DOCKER_TAG:-latest}
user: ${OC_CONTAINER_UID_GID:-1000:1000}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I do not know how collabora reacts with that change. I think we can omit that, because collabora is not accessing opencloud volumes.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @micbar,
the collaboration container uses the opencloud image and has OC_CONFIG_DIR mounted as volume which is why there is the need to adopt the user.
The collabora image configuration starts at line 49 and for the collabora container there is no change of the user exactly for the reason you mentioned (no mounted volumes).

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, then i misread the change. Fine.

@chillymattster

chillymattster commented Nov 21, 2025 •

Copy link
Copy Markdown
Contributor Author

Hi @micbar,
sorry to bother again. I would kindly like to ask about the status of merging this request?
At least from my external view there is no visible progress but I'm not part of the Dev-Team or any possible internal discussions or tests, which is why it feels like being forgotten somehow. Additionally I'm pinging here, as there is a deadline for a release mentioned in other PRs or issue discussions so I'm a bit worried that this PR won't be included in the release any more.

As an external contributor I would very much appreciate slightly more transparency on the progress or handling or any further thoughts of this PR because from an outside perspective there are other things ongoing and other PRs are created and merged quite fast. 🙂

Cheers

@bjesuiter

Copy link
Copy Markdown

Is this merged now? I'm also very interested in this, i cannot use opencloud with my current setup without being able to set the UID and GID :/

@micbar

micbar commented Nov 25, 2025

Copy link
Copy Markdown
Member

I already approve that last week. Will merge it now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants