| 1 | 1 |
new file mode 100644 |
| ... | ... |
@@ -0,0 +1,4 @@ |
| 0 |
+The `contrib` directory contains scripts, images, and other helpful things |
|
| 1 |
+which are not part of the core docker distribution. Please note that they |
|
| 2 |
+could be out of date, since they do not receive the same attention as the |
|
| 3 |
+rest of the repository. |
| 0 | 4 |
new file mode 100755 |
| ... | ... |
@@ -0,0 +1,40 @@ |
| 0 |
+#!/bin/bash |
|
| 1 |
+# Generate a very minimal filesystem based on busybox-static, |
|
| 2 |
+# and load it into the local docker under the name "busybox". |
|
| 3 |
+ |
|
| 4 |
+BUSYBOX=$(which busybox) |
|
| 5 |
+[ "$BUSYBOX" ] || {
|
|
| 6 |
+ echo "Sorry, I could not locate busybox." |
|
| 7 |
+ echo "Try 'apt-get install busybox-static'?" |
|
| 8 |
+ exit 1 |
|
| 9 |
+} |
|
| 10 |
+ |
|
| 11 |
+set -e |
|
| 12 |
+ROOTFS=/tmp/rootfs-busybox-$$-$RANDOM |
|
| 13 |
+mkdir $ROOTFS |
|
| 14 |
+cd $ROOTFS |
|
| 15 |
+ |
|
| 16 |
+mkdir bin etc dev dev/pts lib proc sys tmp |
|
| 17 |
+touch etc/resolv.conf |
|
| 18 |
+cp /etc/nsswitch.conf etc/nsswitch.conf |
|
| 19 |
+echo root:x:0:0:root:/:/bin/sh > etc/passwd |
|
| 20 |
+echo root:x:0: > etc/group |
|
| 21 |
+ln -s lib lib64 |
|
| 22 |
+ln -s bin sbin |
|
| 23 |
+cp $BUSYBOX bin |
|
| 24 |
+for X in $(busybox --list) |
|
| 25 |
+do |
|
| 26 |
+ ln -s busybox bin/$X |
|
| 27 |
+done |
|
| 28 |
+rm bin/init |
|
| 29 |
+ln bin/busybox bin/init |
|
| 30 |
+cp /lib/x86_64-linux-gnu/lib{pthread,c,dl,nsl,nss_*}.so.* lib
|
|
| 31 |
+cp /lib/x86_64-linux-gnu/ld-linux-x86-64.so.2 lib |
|
| 32 |
+for X in console null ptmx random stdin stdout stderr tty urandom zero |
|
| 33 |
+do |
|
| 34 |
+ cp -a /dev/$X dev |
|
| 35 |
+done |
|
| 36 |
+ |
|
| 37 |
+tar -cf- . | docker put busybox |
|
| 38 |
+docker run -i -a -u root busybox /bin/echo Success. |
|
| 39 |
+ |