diff --git a/scripts/Dockerfile b/scripts/Dockerfile
index 62dbaba2937e0b673bd1cce83f5c5c6d39358792..b9f5e9318f42e99bba4a38e8af7a0ce8195878ef 100644
--- a/scripts/Dockerfile
+++ b/scripts/Dockerfile
@@ -1,35 +1,34 @@
 FROM debian:jessie 
 MAINTAINER Marek Vavrusa <marek.vavrusa@nic.cz>
 
-# Nprocs
-ENV THREADS 4 
-
-# Install dependencies and sources 
-RUN apt-get -y update; \
-apt-get install -y \
-build-essential \
-git-core \
-libtool \
-autoconf \
-flex \
-bison \
-libssl-dev \
-liburcu-dev \
-pkg-config \
-liblmdb-dev; \
-# Trim down the image
-apt-get clean && rm -rf /var/lib/apt/lists/* /tmp/*
-
-# Fetch and compile sources
-RUN mkdir /src; \
-git clone https://gitlab.labs.nic.cz/labs/knot.git /src/knot; \
-cd /src/knot && autoreconf -if && ./configure && make -j${THREADS} && make install && ldconfig; \
-# Trim down the image
-rm -rf /src
-
 # Select entrypoint
 WORKDIR /root
 CMD ["/usr/local/sbin/knotd"]
 
 # Expose port
 EXPOSE 53
+
+# Environment
+ENV THREADS 4
+ENV BUILD_PKGS git-core make gcc libtool autoconf pkg-config flex bison libssl-dev liburcu-dev liblmdb-dev
+ENV RUNTIME_PKGS libssl1.0.0 liburcu2 liblmdb0
+
+# Install dependencies and sources
+RUN apt-get -q -y update && \
+apt-get install -q -y ${BUILD_PKGS} ${RUNTIME_PKGS} && \
+# Compile sources
+git clone -b master https://gitlab.labs.nic.cz/labs/knot.git /knot-src && \
+cd /knot-src && \
+autoreconf -if && \
+./configure --disable-static && \
+make -j${THREADS} && \
+make check && \
+make install && \
+ldconfig && \
+# Trim down the image
+cd && \
+rm -rf /knot-src && \
+apt-get purge -q -y ${BUILD_PKGS} && \
+apt-get autoremove -q -y && \
+apt-get clean && \
+rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*