In my previous post (http://glaudiston.blogspot.com.br/2015/06/how-to-make-very-very-small-docker.html ), I did a docker image from scratch for running bash. But bash itself don't solve many problems. We need to add our tools and dependencies.I really don't know a tool to do it, so I wrote a bash script to solve that:#!/bin/bash# use:# getbash.sh /path/to/lib-or-elf.soLIBLD=/lib64/ld-linux-x86-64.so.2;LIB="$1";function getdeps(){ { echo "$1"; $LIBLD --list $1 | cut -d' ' -f3 | sort | uniq | while read f; do [ ! "$f" == "" ] && [ "$(echo -e "$deps" | grep -c "$f")" == "0" ] && { deps="$deps\n$f"; getdeps "$f"; }; done; } | sort | uniq;}getdeps "${LIB}"It just use the ld lib to list dependencies and extract the current path to it. Of course it don't can get another resources used by those libs but already is itself a lot of help on tracking it's dependencies.So, in simples cases, it's halfway to get you static elf in docker running. You can choice if you want to copy all path or just all libs. I think it's better to copy all to one place like:mkdir deplibs && ./getdeps.sh "/path/to/your/elf" | xargs -i cp -v "{}" ./deplibs;Another simple script can copy all dependencies to a deps dir in current directory structure../getdeps.sh "/path/to/your/elf" | while read f; do d="./deps/$(dirname "$f")"; [ ! -e "$d" ] && mkdir -pv "$d"; cp -v "$f" "$d"; done;Don't forget to set the LD_LIBRARY_PATH or the /etc/ld.so.conf, according your choice.If you put all your deps in a dir named deplibs, just add these 2 lines to your Dockerfile:COPY deps/libs /deplibsENV LD_LIBRARY_PATH /deplibsAt this time you probably already know how proceed with your Dockerfile. I digging in the docker, and I found docker image containers too bigger than they need to be.If you want a really small and functional docker image, look at "alpine", it uses actually 5.242MB, and has a bash and package manager. I really appreciate this image.Anyway, I'm just too curious to stay on others job, I need to do it from myself, understand, and then I can accept that others has a better solution and just use it.In this way, I did started a research to make my own basic functional image.If you just want a basic structure to use docker with low space usage, use "docker run -ti alpine sh" and be happy. if you, as me, feel the need to learn more, keep reading.The docker documentation show us how to create a image from scratch.http://docs.docker.com/articles/baseimages/#creating-a-simple-base-image-using-scratchIt's justFROM scratchCOPY true-asm /trueCMD ["/true"]If you have a statically linked program, it's all you need to know. Just copy your program and set it in CMD.A nice sample is here in this article/tutorial to create a "go" web server:http://blog.xebia.com/2014/07/04/create-the-smallest-possible-docker-container/But what about a really clean docker image for dynamic linked programs? what about run bash in a smaller possible docker?Well, for it we need to learn/remember some concepts.To avoid keep this post to big, you can learn this concepts here:http://www.ibm.com/developerworks/library/l-lpic1-v3-102-3/l-lpic1-v3-102-3-pdf.pdfIn theory, we just need to detect all the dependencies using "ld.so --list" and copy it to our scratch docker.Let's do a docker image to run