dockerlib: fix initcontainer for boot2docker users
authorAugie Fackler <augie@google.com>
Wed, 06 May 2015 14:36:17 -0400
changeset 24970 33055069e465
parent 24969 227b9b2a57a3
child 24971 ab75baaf81d5
dockerlib: fix initcontainer for boot2docker users This allows me to build rpm packages using boot2docker on my Mac. It's probably a very fragile hack, but it seems to work well enough for now that I felt it was worth sharing.
contrib/dockerlib.sh
--- a/contrib/dockerlib.sh	Wed May 06 10:45:51 2015 -0400
+++ b/contrib/dockerlib.sh	Wed May 06 14:36:17 2015 -0400
@@ -29,7 +29,14 @@
   DBUILDUSER=build
   (
     cat $DFILE
-    echo RUN groupadd $DBUILDUSER -g `id -g`
-    echo RUN useradd $DBUILDUSER -u `id -u` -g $DBUILDUSER
+    if [ $(uname) = "Darwin" ] ; then
+        # The builder is using boot2docker on OS X, so we're going to
+        # *guess* the uid of the user inside the VM that is actually
+        # running docker. This is *very likely* to fail at some point.
+        echo RUN useradd $DBUILDUSER -u 1000
+    else
+        echo RUN groupadd $DBUILDUSER -g `id -g`
+        echo RUN useradd $DBUILDUSER -u `id -u` -g $DBUILDUSER
+    fi
   ) | $DOCKER build --tag $CONTAINER -
 }