Skip to content

Commit ba63e71

Browse files
committed
change Docker image to run as nonroot for k8s clusters restricting to runAsNonRoot
Refs: elastic/elastic-otel-node#1398
1 parent 5c0b40f commit ba63e71

2 files changed

Lines changed: 8 additions & 2 deletions

File tree

operator/Dockerfile

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,11 @@ RUN pip install --no-cache-dir --target workspace /opt/distro/*.whl -r requireme
3838

3939
FROM ${IMAGE}:${IMAGE_VERSION}
4040

41-
COPY --from=build /operator-build/workspace /autoinstrumentation
42-
COPY --from=build-musl /operator-build/workspace /autoinstrumentation-musl
41+
COPY --chown=65532:65532 --from=build /operator-build/workspace /autoinstrumentation
42+
COPY --chown=65532:65532 --from=build-musl /operator-build/workspace /autoinstrumentation-musl
43+
44+
# Use wolfi's "nonroot" user/group to satisfy k8s runAsNonRoot security policies.
45+
USER 65532:65532
4346

4447
RUN chmod -R go+r /autoinstrumentation
4548
RUN chmod -R go+r /autoinstrumentation-musl

operator/Dockerfile.alpine

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,4 +17,7 @@ FROM python:3.12-alpine3.22@sha256:f6973b8f9395204414a7f25d99a50ba1c7306064771d1
1717

1818
COPY --from=build /operator-build/workspace /autoinstrumentation
1919

20+
# Use "nobody" user, to mimic the non-root "nonroot" user/group used in Dockerfile.
21+
USER 65534:65534
22+
2023
RUN chmod -R go+r /autoinstrumentation

0 commit comments

Comments
 (0)