Call me lazy; I don't like doing the same thing over and over when it comes to writing code; same for Dockerfiles as well. I have been following various formula that I gathered from various sources; primarily from this post of Dave Beckett's . After a while, I thought I will put them together into a script that can easily be consumed from my Dockerfiles. Here is the outcome; have a look at my github repo codemedic/debian-docker-build-tools . The README has an example that will help you how to use it. The scheme used here has two main intentions; use backend agnostic primitives (function names) to perform package related tasks, and provide backend specific auto-cleanup to remove package manager artefacts. This paves way to the possibility of using a different (non-debian, say alpine or centos) base image with a different version of these scripts, in a generic and more readable fashion; and it will tidy up after itself, leading to smaller images.