-
Notifications
You must be signed in to change notification settings - Fork 97
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Enable to share single image with multiple users. Create user in run-…
…time to use same UDI/GID as host user. See https://qiita.com/ktamido/items/8d7b7eddbd88bd1bbf99
- Loading branch information
Showing
7 changed files
with
40 additions
and
54 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
#!/bin/bash | ||
|
||
function fail { | ||
printf '\033[31m%s\033[0m\n' "$1" >&2 ## Send message to stderr. | ||
exit "${2-1}" ## Return a code specified by $2, or 1 by default. | ||
} | ||
[ -z "${HOST_UID}" ] && fail "ERROR: HOST_UID is requried, add '-e HOST_UID=$(id -u)' to your docker commandline option" | ||
[ -z "${HOST_GID}" ] && fail "ERROR: HOST_GID is requried, add '-e HOST_GID=$(id -g)' to your docker commandline option" | ||
|
||
# create user with same UID as the host user | ||
# -g The numerical value of the group's ID. | ||
groupadd -g $HOST_GID user | ||
# -u The numerical value of the user's ID. | ||
# -o Allow the creation of a user account with a duplicate (non-unique) UID. | ||
# -m Create the user's home directory if it does not exist. | ||
# -g The group name or number of the user's initial login group. | ||
# -s The name of the user's login shell. | ||
useradd -u $HOST_UID -o -m -g $HOST_GID -s /usr/bin user | ||
export HOME=/home/user | ||
cd $HOME | ||
|
||
runuser -u user -- "$@" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,33 +1,25 @@ | ||
#!/bin/bash | ||
|
||
IMAGE_NAME="${IMAGE_NAME:-ros1-unitree}" | ||
TARGET_MACHINE="${TARGET_MACHINE:-arm64v8}" | ||
HOST_INSTALL_ROOT="${BASE_ROOT:-${PWD}}/"${TARGET_MACHINE}_System | ||
INSTALL_ROOT=System | ||
SOURCE_ROOT=${TARGET_MACHINE}_User | ||
|
||
set -xeuf -o pipefail | ||
|
||
case ${OSTYPE} in | ||
linux*) | ||
OPTIONS="-u $(id -u $USER)" | ||
;; | ||
darwin*) | ||
OPTIONS="" | ||
;; | ||
esac | ||
|
||
# -v ${PWD}/${TARGET_MACHINE}_ws_system:/home/user/${TARGET_MACHINE}_ws_system:rw \ | ||
# run on docker | ||
docker run -it --rm \ | ||
${OPTIONS} \ | ||
-e HOST_UID=$(id -u) -e HOST_GID=$(id -g) \ | ||
-e INSTALL_ROOT=${INSTALL_ROOT} \ | ||
-v ${HOST_INSTALL_ROOT}/ros1_dependencies:/opt/jsk/${INSTALL_ROOT}/ros1_dependencies:ro \ | ||
-v ${HOST_INSTALL_ROOT}/Python:/opt/jsk/${INSTALL_ROOT}/Python:ro \ | ||
-v ${HOST_INSTALL_ROOT}/ros1_inst:/opt/jsk/${INSTALL_ROOT}/ros1_inst:ro \ | ||
-v ${HOST_INSTALL_ROOT}/ros1_dependencies_setup.bash:/opt/jsk/${INSTALL_ROOT}/ros1_dependencies_setup.bash:ro \ | ||
-v ${HOST_INSTALL_ROOT}/system_setup.bash:/opt/jsk/${INSTALL_ROOT}/system_setup.bash:ro \ | ||
-v ${PWD}/${SOURCE_ROOT}:/opt/jsk/User:rw \ | ||
ros1-unitree:${TARGET_MACHINE} \ | ||
${IMAGE_NAME}:${TARGET_MACHINE} \ | ||
bash -c "echo 'source /opt/jsk/User/user_setup.bash; env; cd /opt/jsk/User' > ~/.bashrc; exec \"\$0\"" | ||
|
||
# https://stackoverflow.com/questions/59814742/docker-run-bash-init-file |