TUN-9540: Use numeric user id for Dockerfiles
## Summary This commit changes the USER instruction in our Dockerfiles from using the string "nonroot" to its numeric ID "65532". This change is necessary because Kubernetes does not support string-based user IDs in security contexts, requiring numeric IDs instead. The nonroot user maps to 65532 in distroless images.
This commit is contained in:
parent
6ec699509d
commit
ae197908be
|
|
@ -27,8 +27,11 @@ LABEL org.opencontainers.image.source="https://github.com/cloudflare/cloudflared
|
||||||
# copy our compiled binary
|
# copy our compiled binary
|
||||||
COPY --from=builder --chown=nonroot /go/src/github.com/cloudflare/cloudflared/cloudflared /usr/local/bin/
|
COPY --from=builder --chown=nonroot /go/src/github.com/cloudflare/cloudflared/cloudflared /usr/local/bin/
|
||||||
|
|
||||||
# run as non-privileged user
|
# run as nonroot user
|
||||||
USER nonroot
|
# We need to use numeric user id's because Kubernetes doesn't support strings:
|
||||||
|
# https://github.com/kubernetes/kubernetes/blob/v1.33.2/pkg/kubelet/kuberuntime/security_context_others.go#L49
|
||||||
|
# The `nonroot` user maps to `65532`, from: https://github.com/GoogleContainerTools/distroless/blob/main/common/variables.bzl#L18
|
||||||
|
USER 65532:65532
|
||||||
|
|
||||||
# command / entrypoint of container
|
# command / entrypoint of container
|
||||||
ENTRYPOINT ["cloudflared", "--no-autoupdate"]
|
ENTRYPOINT ["cloudflared", "--no-autoupdate"]
|
||||||
|
|
|
||||||
|
|
@ -22,8 +22,11 @@ LABEL org.opencontainers.image.source="https://github.com/cloudflare/cloudflared
|
||||||
# copy our compiled binary
|
# copy our compiled binary
|
||||||
COPY --from=builder --chown=nonroot /go/src/github.com/cloudflare/cloudflared/cloudflared /usr/local/bin/
|
COPY --from=builder --chown=nonroot /go/src/github.com/cloudflare/cloudflared/cloudflared /usr/local/bin/
|
||||||
|
|
||||||
# run as non-privileged user
|
# run as nonroot user
|
||||||
USER nonroot
|
# We need to use numeric user id's because Kubernetes doesn't support strings:
|
||||||
|
# https://github.com/kubernetes/kubernetes/blob/v1.33.2/pkg/kubelet/kuberuntime/security_context_others.go#L49
|
||||||
|
# The `nonroot` user maps to `65532`, from: https://github.com/GoogleContainerTools/distroless/blob/main/common/variables.bzl#L18
|
||||||
|
USER 65532:65532
|
||||||
|
|
||||||
# command / entrypoint of container
|
# command / entrypoint of container
|
||||||
ENTRYPOINT ["cloudflared", "--no-autoupdate"]
|
ENTRYPOINT ["cloudflared", "--no-autoupdate"]
|
||||||
|
|
|
||||||
|
|
@ -22,8 +22,11 @@ LABEL org.opencontainers.image.source="https://github.com/cloudflare/cloudflared
|
||||||
# copy our compiled binary
|
# copy our compiled binary
|
||||||
COPY --from=builder --chown=nonroot /go/src/github.com/cloudflare/cloudflared/cloudflared /usr/local/bin/
|
COPY --from=builder --chown=nonroot /go/src/github.com/cloudflare/cloudflared/cloudflared /usr/local/bin/
|
||||||
|
|
||||||
# run as non-privileged user
|
# run as nonroot user
|
||||||
USER nonroot
|
# We need to use numeric user id's because Kubernetes doesn't support strings:
|
||||||
|
# https://github.com/kubernetes/kubernetes/blob/v1.33.2/pkg/kubelet/kuberuntime/security_context_others.go#L49
|
||||||
|
# The `nonroot` user maps to `65532`, from: https://github.com/GoogleContainerTools/distroless/blob/main/common/variables.bzl#L18
|
||||||
|
USER 65532:65532
|
||||||
|
|
||||||
# command / entrypoint of container
|
# command / entrypoint of container
|
||||||
ENTRYPOINT ["cloudflared", "--no-autoupdate"]
|
ENTRYPOINT ["cloudflared", "--no-autoupdate"]
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue