run as non root user in container
Author: ghostCreated Apr 10, 2025Updated Sep 28, 2026
Labelskind/enhancementarea/infrastructurecontributor/wanted
Welcome!
- Yes, I've searched similar issues on GitHub and didn't find any.
- Yes, I've searched similar issues on the Traefik community forum and didn't find any.
What did you expect to see?
Currently, the official container for traefik runs as root. In the event that the container runtime is also running as root, this results in a process that runs as root on the host. More generally, it makes sense to not run as root following the principle of least privilege.
For quite some time we have been using the following dockerfile to produce a traefik container that does not run as root. We run traefik on K3S, and I am not aware of any differences in behavior from the default image.
ARG TRAEFIK_VERSION=3.3.5
ARG ALPINE_VERSION=latest
# Official image
FROM traefik:$TRAEFIK_VERSION AS source
# Rootless customization
FROM alpine:$ALPINE_VERSION AS build
RUN apk --no-cache add libcap
COPY --from=source /usr/local/bin/traefik /
# necessary for non root users to bind low numbered ports
RUN setcap cap_net_bind_service=+ep /traefik
# Final image
FROM scratch
COPY --from=source /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/
COPY --from=source /usr/share/zoneinfo /usr/share/
COPY --from=build /traefik /
USER 10001:10001
ENTRYPOINT ["/traefik"]Are there any reasons why the official traefik conatiner can't run as root? If not would there be any appetite to accept a PR to make the official image not run as root?
Source: traefik/traefik