/bin/bash:create a clean directory called docker_bash and enter it.mkdir docker_bash;cd docker_bash;Let's create a Dockerfile to build our image, and see how much space we use:echo "FROM scratch" > Dockerfiledocker build -t docker_bash .Sending build context to Docker daemon 2.048 kBSending build context to Docker daemon Step 0 : FROM scratch ---> Step 1 : CMD /bin/bash ---> Running in 61af7327eb2e ---> aeb4860259eaRemoving intermediate container 61af7327eb2eSuccessfully built aeb4860259eaNow we can see that we have a empty image result zero bytes:$ docker images |grep docker_bashdocker_bash latest aeb4860259ea 8 seconds ago 0 BMy intent is to run a dynamic linked program (bash), so what my dependencies ? the ld.so can say it. To show what is your ld.so, just use:$ ls /lib/ld-* -l-rwxr-xr-x 1 root root 163500 Abr 10 2013 /lib/ld-2.17.solrwxrwxrwx 1 root root 10 Abr 8 2013 /lib/ld-linux-x86-64.so.2 -> ld-2.17.so$ /lib/ld-2.17.so --list /bin/bash linux-vdso.so.1 (0x00007ffcb03ba000) libreadline.so.6 => /lib64/libreadline.so.6 (0x00007fbee994c000) libhistory.so.6 => /lib64/libhistory.so.6 (0x00007fbee9744000) libncursesw.so.5 => /lib64/libncursesw.so.5 (0x00007fbee94e1000) libdl.so.2 => /lib64/libdl.so.2 (0x00007fbee92dd000) libc.so.6 => /lib64/libc.so.6 (0x00007fbee8f30000) /lib64/ld-linux-x86-64.so.2 => /lib/ld-2.17.so (0x00007fbee9ba8000)Here you are, all your dependencies. You can do the same in each lib listed to ensure it has no others dependencies. I'm not sure "ld.so --list" show recursive dependencies, I don't think so. But for bash is just these.The COPY command in Dockerfile just copy from current directory and below, so we need to copy those deps to current directory structure:$ mkdir {lib{,64},bin}$ cp /lib64/ld-2.17.so lib64/$ ln -sv /lib64/ld-2.17.so lib64/ld-linux-x86-64.so.2lib64/ld-linux-x86-64.so.2 -> /lib64/ld-2.17.so$ cp /lib64/libc.so.6 lib64/$ cp /lib64/libdl.so.2 lib64/$ cp /lib64/libncursesw.so.5 lib64/$ cp /lib64/libhistory.so.6 lib64/$ cp /lib64/libreadline.so.6 lib64/$ cp /bin/bash bin/Note the symlink was created to our root, but in our image it's correct.We can use chroot to test our structure:$ sudo chroot $PWD/ /lib64/ld-linux-x86-64.so.2 Usage: ld.so [OPTION]... EXECUTABLE-FILE [ARGS-FOR-PROGRAM...]You have invoked `ld.so', the helper program for shared library executables.This program usually lives in the file `/lib/ld.so', and special directivesin executable files using ELF shared libraries tell the system's programloader to load the helper program from this file. This helper program loadsthe shared libraries needed by the program executable, prepares the programto run, and runs it. You may invoke this helper program directly from thecommand line to load and run an ELF executable file; this is like executingthat file itself, but always uses this helper program from the file youspecified, instead of the helper program file specified in the executablefile you run. This is mostly of use for maintainers to test new versionsof this helper program; chances are you did not intend to run this program. --list list all dependencies and how they are resolved --verify verify that given object really is a dynamically linked object we can handle --inhibit-cache Do not use /etc/ld.so.cache --library-path PATH use given PATH instead of content of the environment variable LD_LIBRARY_PATH --inhibit-rpath LIST ignore RUNPATH and RPATH information in object names in LIST --audit LIST use objects named in LIST as auditorsld.so is static and worked in chroot.What about bash ?$ sudo chroot $PWD/ /bin/bashI have no name!:/$ You can play with bash bultin commands. When you ready to continue, just exit.Time to build our image and see how it