Build Wheezy

First install debootstrap

$ sudo apt-get install debootstrap

Then prepare the root directory

$ mkdir -p /vdisks/chroot/wheezy

Finally build a Wheezy system

$ sudo debootstrap wheezy /vdisks/chroot/wheezy http://ftp.us.debian.org/debian

At this point you have a small environment which you can chroot into and modify it the way you like

$ sudo chroot /vdisks/chroot/wheezy /bin/bash

You will drop to a bash shell in the newly created system, I won’t do any further changes to this system except modifying the banner

# echo "Debian 7 Docker image" > /etc/motd # exit

Import Docker Image

Now let’s import this new system into docker:

$ sudo tar -C wheezy/ -c . | docker import - aossama/wheezy cec2131b98fdfd41d83437509fea930a949f7cd074b66c36a0a6def8e26b5d02

If the import goes well, you will see the ID of the newly imported image

First check the images list:

$ docker images REPOSITORY TAG IMAGE ID CREATED VIRTUAL SIZE aossama/wheezy latest cec2131b98fd 2 minutes ago 218.6 MB

And start the new image

$ docker run --rm --name=wheezy aossama/wheezy cat /etc/motd Debian 7 Docker image

And voilà, you just built a new docker image, imported it, and ready to dockerize it.