浏览代码

Dockerfile: use non-privileged user account (#16052)

Federico Gimenez 7 年之前
父节点
当前提交
50dbe8e244
共有 2 个文件被更改,包括 12 次插入0 次删除
  1. 6 0
      Dockerfile
  2. 6 0
      Dockerfile.alltools

+ 6 - 0
Dockerfile

@@ -12,5 +12,11 @@ FROM alpine:latest
 RUN apk add --no-cache ca-certificates
 RUN apk add --no-cache ca-certificates
 COPY --from=builder /go-ethereum/build/bin/geth /usr/local/bin/
 COPY --from=builder /go-ethereum/build/bin/geth /usr/local/bin/
 
 
+RUN addgroup -g 1000 geth && \
+    adduser -h /root -D -u 1000 -G geth geth && \
+    chown geth:geth /root
+
+USER geth
+
 EXPOSE 8545 8546 30303 30303/udp 30304/udp
 EXPOSE 8545 8546 30303 30303/udp 30304/udp
 ENTRYPOINT ["geth"]
 ENTRYPOINT ["geth"]

+ 6 - 0
Dockerfile.alltools

@@ -12,4 +12,10 @@ FROM alpine:latest
 RUN apk add --no-cache ca-certificates
 RUN apk add --no-cache ca-certificates
 COPY --from=builder /go-ethereum/build/bin/* /usr/local/bin/
 COPY --from=builder /go-ethereum/build/bin/* /usr/local/bin/
 
 
+RUN addgroup -g 1000 geth && \
+    adduser -h /root -D -u 1000 -G geth geth \
+    chown geth:geth /root
+
+USER geth
+
 EXPOSE 8545 8546 30303 30303/udp 30304/udp
 EXPOSE 8545 8546 30303 30303/udp 30304/udp