cgswong/min-jessie

By cgswong

Updated over 9 years ago

A minimal Debian GNU/Linux 8 (Jessie) Docker image, currently ~80 MB.

Image
1

1.7K

Overview

A lot of the publicly available Docker base images and derivatives are pretty large for being light-weight, minimal images, having unneeded applications installed and taking up space. My goal here is to create an absolutely minimal base Docker image, based on Debian. To accomplish this I also use the docker-squash tool to free more space in the container before committing and checking in the image here. While BusyBox is a great alternative, I prefer a Debian base given it's wide user base, supportability and familiarity. Though I'll try my hand at BusyBox as well.

Usage

If you just want to use this image, pull it and configure what you want:

docker pull cgswong/min-jessie

To use this image in your own project, use this FROM line in your Dockerfile:

FROM cgswong/min-jessie:latest
Build

Below are the steps I've taken to build this image. Note that in the interest of brievity I've not included the steps I've used to remove all the unwanted packages.

  1. Pull the (official base Debian Jessie image)[https://registry.hub.docker.com/_/debian/]:

docker pull debian:jessie

  1. Get the image ID, docker images |grep jessie, and run the container, docker run -it debian:jessie /bin/bash

Notice how small it is to start with.

# docker images
REPOSITORY             TAG                 IMAGE ID            CREATED             VIRTUAL SIZE
debian                 jessie              0e30e84e9513        2 weeks ago         122.8 MB
  1. Run and enter the new container:
docker run -it 0e30e84e9513 /bin/bash
  1. Inside the container, run the following:
apt-get -y update && apt-get -y dist-upgrade
apt-get -y clean && apt-get -y autoclean && apt-get -y autoremove
cp -R /usr/share/locale/en\@* /tmp/ && rm -rf /usr/share/locale/* && mv /tmp/en\@* /usr/share/locale/
rm -rf /var/cache/debconf/*-old && rm -rf /var/lib/apt/lists/* && rm -rf /usr/share/doc/*
echo "`cat /etc/issue.net` Docker Image - cgswong/min-jessie - `date +'%Y/%m/%d'`" > /etc/motd
exit
  1. Commit those changes:
# docker ps -a
CONTAINER ID        IMAGE                         COMMAND                CREATED             STATUS                     PORTS               NAMES
042b883dc723        debian:jessie                 "/bin/bash"            3 minutes ago       Exited (0) 8 seconds ago                       clever_fermi

# docker commit  042b883dc723
8bdbcea2f1c9516fa18e2be80cda4cdb331699c7468f59ab25a5c28e45716f09
  1. Squash the image and get its new ID:
# docker save 8bdbcea2f1c9516fa18e2be80cda4cdb331699c7468f59ab25a5c28e45716f09 | docker-squash -from root -t cgswong/min-jessie | docker load
  1. Check the final size:
# docker images
REPOSITORY             TAG                 IMAGE ID            CREATED             VIRTUAL SIZE
cgswong/jessie         latest              7086d9406a02        56 seconds ago      83.08 MB
  1. Push it to the Docker registry:
docker push cgswong/min-jessie

That's it! Feedback is welcome.

Docker Pull Command

docker pull cgswong/min-jessie