Skip to content

Don't run as root in Docker container - #140

Open
MoeRT09 wants to merge 1 commit into
meshcloud:mainfrom
MoeRT09:dont-run-as-root
Open

MoeRT09 wants to merge 1 commit into
meshcloud:mainfrom
MoeRT09:dont-run-as-root

Conversation

@MoeRT09

@MoeRT09 MoeRT09 commented Sep 3, 2024

Copy link
Copy Markdown

It is considered bad practice to let applications run as root in a Docker container. Furthermore, this might even be prohibited in some environments. In order to lower the attack surface, the application is executed as an unprivileged user with this PR.

@JohannesRudolph JohannesRudolph left a comment

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.

lgtm

Comment thread Dockerfile
ARG UID=1005

COPY --from=builder /build/build/libs/unipipe-service-broker-1.0.0.jar /app/
COPY --chown=0:0 --chmod=555 --from=builder /build/build/libs/unipipe-service-broker-1.0.0.jar /app/

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.

can the chown command in the COPY and in the RUN instruction below be combined into the COPY instruction already?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

No not really, the idea was that the jar is owned by root and can only be executed (not modified) by other users. While the /app itself must be writeable for the unprivileged container user, which runs the jar as it writes the SSH key into the /app/tmp directory (and also creates the /app/tmp directory after #139 )

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