Skip to contentSkip to conversation

automation: introduce a new variable to control container user

PATCH Superseded Wei Liu 2 participants 3 messages Sep 24, 2018 – Sep 25, 2018

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore

Wei Liu

author
#0 lore raw

PATCH 1/1 automation: introduce a new variable to control container user

Sometimes it is handy to create a container and play as root with its setup manually.

---
 automation/scripts/containerize | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)
automation/scripts/containerize +7 -1
index bf9af589a8..ea3c7378aa 100755
@@ -23,6 +23,12 @@ case "_${CONTAINER}" in
     _stretch|_) CONTAINER="${BASE}/debian:stretch" ;;
 esac
 
+# Use this variable to control whehter root should be used
+case "_${CONTAINER_ROOT}" in
+    _1)   userarg= ;;
+    _0|_) userarg="-u $(id -u)" ;;
+esac
+
 # Save the commands for future use
 cmd=$@
 
@@ -70,7 +76,7 @@ fi
 # Kick off Docker
 einfo "*** Launching container ..."
 exec docker run \
-    -u $(id -u) \
+    ${userarg} \
     ${SSH_AUTH_SOCK:+-e SSH_AUTH_SOCK="/tmp/ssh-agent/${SSH_AUTH_NAME}"} \
     -v "${CONTAINER_PATH}":/build:rw \
     -v "${HOME}/.ssh":/root/.ssh:ro \
Signature · 7 lines
2.11.0


_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
#1 lore raw
Quoted 13 lines · Wei Liu

Sometimes it is handy to create a container and play as root with its setup manually.

---
 automation/scripts/containerize | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)
automation/scripts/containerize +0 -0
index bf9af589a8..ea3c7378aa 100755

automation/scripts/containerize case "_${CONTAINER}" in · line 30

Quoted 8 lines
automation/scripts/containerize +5 -0
@@ -23,6 +23,12 @@ case "_${CONTAINER}" in
     _stretch|_) CONTAINER="${BASE}/debian:stretch" ;;
 esac
 
+# Use this variable to control whehter root should be used
+case "_${CONTAINER_ROOT}" in
+    _1)   userarg= ;;
+    _0|_) userarg="-u $(id -u)" ;;
+esac

How would you feel about CONTAINER_UID0 instead? I just fear that "ROOT" has quite a few meanings. e.g top of the filesystem? The working dir inside of the container?

Mind documenting this in automation/build/README.md ? I should likely move part of this file that describes the variables up a directory.

--
Doug

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel

author
#2 lore raw
Quoted 17 lines · Doug Goldstein
Quoted 16 lines · Wei Liu

Sometimes it is handy to create a container and play as root with its setup manually.

---
 automation/scripts/containerize | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)
automation/scripts/containerize +0 -0
index bf9af589a8..ea3c7378aa 100755
@@ -23,6 +23,12 @@ case "_${CONTAINER}" in
     _stretch|_) CONTAINER="${BASE}/debian:stretch" ;;
 esac
 
Quoted 9 lines

automation/scripts/containerize case "_${CONTAINER}" in · line 30

Quoted 5 lines
automation/scripts/containerize +5 -0
+# Use this variable to control whehter root should be used
+case "_${CONTAINER_ROOT}" in
+    _1)   userarg= ;;
+    _0|_) userarg="-u $(id -u)" ;;
+esac

How would you feel about CONTAINER_UID0 instead? I just fear that "ROOT" has quite a few meanings. e.g top of the filesystem? The working dir inside of the container?

CONTAINER_UID0 is fine.

Quoted 3 lines

Mind documenting this in automation/build/README.md ? I should likely move part of this file that describes the variables up a directory.

Will do.

Wei.

Quoted 3 lines

--
Doug

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel