Skip to content

Commit 70424c8

Browse files
committed
There was an attempt.. it seems the usermod approach won't work
Checking this non working code for the record. The idea is to usermod to change the uid:gid in entrypoint script. There are two approaches I took to do this: 1. pass the -u flag to docker run and try to do the usermod. Won't work because we're not in the passwd file aand so user mod fails 2. pass env vars with the host uid:gid you want to run as, and then usermod to change in-flight (fails, as we're trying to change the uid while logged in/running proc It seems eding the container /etc/passwd file is the only workable approach. One more thing to try is to run eentrypoint.sh before dumbinit - will do that next
1 parent efe1ca8 commit 70424c8

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

entrypoint.sh

+8-4
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,13 @@
1-
#!/bin/sh
1+
#!/bin/bash
22

33
export HOME=/home/coder
4-
export USER_ID=$(id -u)
5-
export GROUP_ID=$(id -g)
64

7-
sudo usermod -u $USER_ID coder && sudo groupmod -g $GROUP_ID coder
5+
if [[ -z $CODER_UID || -z $CODER_GID ]];
6+
then
7+
echo "didn't find CODER_UID or CODER_GID env vars, running with container default uid:gid"
8+
else
9+
echo "found CODER_UID and CODER_GID env vars, running usermod...";
10+
usermod -u $CODER_UID coder && sudo usermod -g $CODER_GID coder372
11+
fi
812

913
exec "$@"

0 commit comments

Comments
 (0)