@@ -22,20 +22,44 @@ COPY . .
22
22
RUN go get -u github.com/jteeuwen/go-bindata/...
23
23
RUN make static && mv img /usr/bin/img
24
24
25
- FROM alpine
25
+ # We don't use the Alpine shadow pkg bacause:
26
+ # 1. Alpine shadow makes SUID `su` executable without password: https://github.com/gliderlabs/docker-alpine/issues/430
27
+ # (but note that the SUID binary is not executable after unsharing the usernamespace. so this issue is not critical)
28
+ # 2. As of early October 2018, the upstream shadow newuidmap/newgidmap depends on CAP_SYS_ADMIN.
29
+ # So we need to apply https://github.com/shadow-maint/shadow/pull/132 .
30
+ FROM alpine AS idmap
31
+ RUN apk add --no-cache autoconf automake build-base byacc gettext gettext-dev gcc git libcap-dev libtool libxslt
32
+ RUN git clone https://github.com/giuseppe/shadow.git \
33
+ && cd shadow \
34
+ && git checkout 336cead97d87be6c4828521f50a992e76a17e442 \
35
+ && ./autogen.sh --disable-nls --disable-man --without-audit --without-selinux --without-acl --without-attr --without-tcb --without-nscd \
36
+ && make \
37
+ && cp src/newuidmap src/newgidmap /usr/bin
38
+
39
+ FROM alpine AS base
26
40
MAINTAINER Jessica Frazelle <
[email protected] >
27
- RUN apk add --no-cache \
28
- bash \
29
- git \
30
- shadow \
31
- shadow-uidmap \
32
- strace
41
+ RUN apk add --no-cache git
33
42
COPY --from=img /usr/bin/img /usr/bin/img
34
43
COPY --from=runc /usr/bin/runc /usr/bin/runc
35
- ENV HOME /home/user
36
- RUN useradd --create-home --home-dir $HOME user \
37
- && chown -R user:user $HOME /run /tmp
44
+ COPY --from=idmap /usr/bin/newuidmap /usr/bin/newuidmap
45
+ COPY --from=idmap /usr/bin/newgidmap /usr/bin/newgidmap
46
+ RUN chmod u+s /usr/bin/newuidmap /usr/bin/newgidmap \
47
+ && adduser -D -u 1000 user \
48
+ && mkdir -p /run/user/1000 \
49
+ && chown -R user /run/user/1000 /home/user \
50
+ && echo user:100000:65536 | tee /etc/subuid | tee /etc/subgid
51
+ # As of v3.8.1, Alpine does not set SUID bit on the busybox version of /bin/su.
52
+ # However, future version may set SUID bit on /bin/su.
53
+ # We lock the root account so as to disable su completely.
54
+ RUN passwd -l root
55
+
56
+ FROM base AS debug
57
+ RUN apk add --no-cache bash strace
58
+
59
+ FROM base AS release
38
60
USER user
39
61
ENV USER user
62
+ ENV HOME /home/user
63
+ ENV XDG_RUNTIME_DIR=/run/user/1000
40
64
ENTRYPOINT [ "img" ]
41
65
CMD [ "--help" ]
0 commit comments