How can I make my own base image for Docker?

According to the Docker documentation, to build your own image, you must always specify a base image using the FROM instruction.

Obviously, there are lots of images to choose from in the Docker index, but what if I wanted to build my own? Is that possible?

The image base is built off Ubuntu if I understand correctly, and I want to experiment with a Debian image. Plus, I want to really understand how Docker works, and the base image is still a blackbox for me.

Edit: official documentation on creating a base image


You can take a look at how the base images are created and go from there.

You can find them here: There is,,

Quoting Solomon Hykes:

You can easily create a new container from any tarball with "docker import". For example:

debootstrap raring ./rootfs
tar -C ./rootfs -c . | docker import - flimm/mybase

(credit to fatherlinux) Get information from , which explains better

  1. Create the tar files for your file system, simply could be

    tar --numeric-owner --exclude=/proc --exclude=/sys -cvf centos6-base.tar /
  2. Transfer the tar file to other docker system if not installed locally and import it

    cat centos6-base.tar | docker import - centos6-base
  3. Now you can verify by running it.

    docker run -i -t centos6-base cat /etc/redhat-release

The scripts from dotcloud combine first two steps together which make me confused and looks complicated in the beginning.

The docker official guideline using debootstrap also tries to make clean file system.

You can judge by yourself how to do step 1.

To start building your own image from scratch, you can use the scratch image.

Using the scratch “image” signals to the build process that you want the next command in the Dockerfile to be the first filesystem layer in your image.

FROM scratch
ADD hello /
CMD ["/hello"]

If you want to make your own base image I would first take a look at Official Images, specifically stackbrew inside that repo.

Otherwise there are some great references for minimal OS images in the docker repo itself.

For example here is a script for making a minimal arch image and there are more here.

Need Your Help

How to find a Java Memory Leak

java memory memory-leaks jhat

How do you find a memory leak in Java (using, for example, JHat)? I have tried to load the heap dump up in JHat to take a basic look. However, I do not understand how I am supposed to be able to fi...

getResourceAsStream() is always returning null

java web-services jboss inputstream

I have the following structure in a Java Web Application: