Skip to content

Commit 5b653f5

Browse files
authored
fix(containers): Allow non-root users to mount fuse filesystems for alpine and buster images (#540)
1 parent 6caef36 commit 5b653f5

File tree

2 files changed

+7
-6
lines changed

2 files changed

+7
-6
lines changed

Dockerfile.alpine

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,12 @@ RUN go build -ldflags "-X main.metadataString=container.alpine" -o cloud_sql_pro
2525
FROM alpine:3
2626
RUN apk add --no-cache \
2727
ca-certificates \
28-
fuse \
2928
libc6-compat
29+
# Install fuse and allow enable non-root users to mount
30+
RUN apk add --no-cache fuse && sed -i 's/^#user_allow_other$/user_allow_other/g' /etc/fuse.conf
3031
# Add a non-root user matching the nonroot user from the main container
3132
RUN addgroup -g 65532 -S nonroot && adduser -u 65532 -S nonroot -G nonroot
32-
# set the uid as an integer for compatibility with runAsNonRoot in Kubernetes
33+
# Set the uid as an integer for compatibility with runAsNonRoot in Kubernetes
3334
USER 65532
3435

3536
COPY --from=build --chown=nonroot /go/src/cloudsql-proxy/cloud_sql_proxy /cloud_sql_proxy

Dockerfile.buster

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,12 @@ RUN go build -ldflags "-X main.metadataString=container.buster" -o cloud_sql_pro
2323

2424
# Final stage
2525
FROM debian:buster
26-
RUN apt-get update && apt-get install -y \
27-
ca-certificates \
28-
fuse
26+
RUN apt-get update && apt-get install -y ca-certificates
27+
# Install fuse and allow enable non-root users to mount
28+
RUN apt-get update && apt-get install -y fuse && sed -i 's/^#user_allow_other$/user_allow_other/g' /etc/fuse.conf
2929
# Add a non-root user matching the nonroot user from the main container
3030
RUN groupadd -g 65532 -r nonroot && useradd -u 65532 -g 65532 -r nonroot
31-
# set the uid as an integer for compatibility with runAsNonRoot in Kubernetes
31+
# Set the uid as an integer for compatibility with runAsNonRoot in Kubernetes
3232
USER 65532
3333

3434
COPY --from=build --chown=nonroot /go/src/cloudsql-proxy/cloud_sql_proxy /cloud_sql_proxy

0 commit comments

Comments
 (0)