Dockerfile to build qdirstat
Von Carsten
Today I wanted to check how much diskspace I wasted in my home directory. On windows I’d use WinDirStat and on linux there is the alternative qdirstat. Unfortunately there is no pre-build binary for my distribution, so I decided to build from source. But I don’t want litter my system with Qt dependencies, so I decided to build it in a docker container. Here’s my Dockerfile:
FROM ubuntu:14.04
RUN apt-get update -y && apt-get install -y build-essential qtbase5-dev zlib1g-dev qttools5-dev-tools qt5-default gdb git
VOLUME ["/usr/target/"]
RUN cd /usr/src && git clone https://github.com/shundhammer/qdirstat.git
RUN echo "\
cd /usr/src/qdirstat/src\n\
qmake\n\
make\n\
cp qdirstat /usr/target\n\
" > /tmp/build.sh
ENTRYPOINT ["/bin/sh", "/tmp/build.sh"]
First you have to create an image from this Dockerfile:
# copy the Dockerfile into a new directory and run the following command in a terminal in that directory
docker build -t moritanosuke/qdirstat .
Now you can start a container from this image to clone and build qdirstat:
# run the container
docker run --rm -it -v $(pwd):/usr/target moritanosuke/qdirstat
Now you should have the executable in the current directory. The owner will be root, but you should be able to run it on your local machine now – assuming that you have all dependencies to run Qt applications already installed. The container was removed right after it completed the build, so the only thing left to do is removing the image:
docker rmi moritanosuke/qdirstat
This is now my preferred way to build random open source projects without messing up my local machine. In earlier times I used full blown VMs with snapshots, but this is even faster.