-
Notifications
You must be signed in to change notification settings - Fork 2
/
entry_point.sh
executable file
·36 lines (26 loc) · 1.05 KB
/
entry_point.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#!/bin/sh
# Override user ID lookup to cope with being randomly assigned IDs using
# the -u option to 'docker run'.
# reference:
# http://blog.dscpl.com.au/2015/12/unknown-user-when-running-docker.html
USER_ID=$(id -u)
GROUP_ID=$(id -g)
if [ x"$USER_ID" != x"0" -a x"$USER_ID" != x"1000" ]; then
# set the new passwd and group files
NSS_WRAPPER_PASSWD=/tmp/passwd.nss_wrapper
NSS_WRAPPER_GROUP=/tmp/group.nss_wrapper
# overwrite the old uid and gid for the user
cat /etc/passwd | sed -e "s/^docker:x:1000:1000:/docker:x:$USER_ID:$GROUP_ID:/" > $NSS_WRAPPER_PASSWD
cat /etc/group | sed -e "s/^docker:x:1000:/docker:x:$GROUP_ID:/" > $NSS_WRAPPER_GROUP
export NSS_WRAPPER_PASSWD
export NSS_WRAPPER_GROUP
LD_PRELOAD=/usr/lib/libnss_wrapper.so
export LD_PRELOAD
fi
# add mitmproxy certificate to the system trusted certs
if [ x"$MITMPROXY_CERT" != x"" -a -r $MITMPROXY_CERT ]; then
sudo cp $MITMPROXY_CERT /usr/local/share/ca-certificates/mitmproxy.crt
sudo update-ca-certificates
fi
# run the user's command
exec "$@"