docker: run geth as non-root user

Establish a dedicated 'geth' user and group to run the process. This follows the principle of least privilege and improves container isolation by avoiding root execution within the final image.
This commit is contained in:
RinCodeForge927 2026-01-10 16:51:36 +07:00
parent 127d1f42bb
commit 33e1129aeb

View file

@ -20,8 +20,13 @@ RUN cd /go-ethereum && go run build/ci.go install -static ./cmd/geth
FROM alpine:latest
RUN apk add --no-cache ca-certificates
RUN addgroup -g 1000 geth && \
adduser -u 1000 -G geth -s /bin/sh -D geth
COPY --from=builder /go-ethereum/build/bin/geth /usr/local/bin/
USER geth
EXPOSE 8545 8546 30303 30303/udp
ENTRYPOINT ["geth"]