Learn how to build the file duplicate finder Czkawka from source on a 2007 Linux Mint machine inside a Docker container. This step-by-step guide walks you through setting up dependencies, building the project with Rust, and running the program. You'll also configure the Docker container for future use and map SAMBA shares for seamless file management. A simple way to keep your system clean and duplicate-free—no 'hiccups'!"

Prerequisites

The only prerequisite is that you have docker available on your host system already.

Process

The process involves running commands on the host system and inside the container, hence in the header section I include in parenthesis the context in which the commands are to be executed.

Initial creation of a suitable container (HOST SYSTEM)

Run the following command to create a docker container running Ubuntu 22.04 and then be ready with a shell prompt:

sudo docker run -it ubuntu:22.04 bash

Prepare the docker container (DOCKER CONTAINER)

Refresh the base Ubuntu 22.04 context and install the necessary toolchain with required dependencies:

  • glib-2.0 >= 2.66
  • cairo >= 1.17.6
  • gtk4 >= 4.4.0
apt update
apt install build-essential meson ninja-build libmount-dev python3 pkg-config git curl
apt install libglib2.0-dev libcairo2-dev libatk1.0-dev libpango1.0-dev libgdk-pixbuf2.0-dev libgtk-3-dev
apt install libgtk-4-dev

Now verify that pkg-config can find the dependencies just installed, and verify that the versions found are sufficient according to Czkawka's needs:

pkg-config --modversion glib-2.0
pkg-config --modversion cairo
pkg-config --modversion gtk4

Install Rust (DOCKER CONTAINER)

Now it is time to install the RUST language, answer the prompt and follow the instructions (I accepted all default settings). Once complete, source the environment and check its version:

curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
source "$HOME/.cargo/env"
rustc --version
rustc 1.81.0 (eeb90cda1 2024-09-04)

Get the latest version of czkawka and build it (DOCKER CONTAINER)

At this point we are ready to get the latest version of czkawka and build it from source. First clone the repository and then build it:

git clone https://github.com/qarmin/czkawka.git
cd czkawka
cargo build --release

If the build was successful (check the exit status of the last command with echo $? ), then move the binaries in a standard location and make them available:

echo $?
czkawka_cli --version
cp ./target/release/czkawka_cli /usr/local/bin/czkawka_cli
cp ./target/release/czkawka_gui /usr/local/bin/czkawka_gui
chmod +x /usr/local/bin/czkawka_cli
chmod +x /usr/local/bin/czkawka_gui

Commit the container (DOCKER CONTAINER and HOST SYSTEM)

Great! At this point your czkawka is ready to run, but it's premature to celebrate a "job well done" because if you want to keep czkawka running across reboots, you need to configure the container to persist...otherwise all the effort spent so far would be wasted. Let us proceed. First, obtain the container ID, and choose one of the two methods below to obtain the container ID:

From within the container -> use the following "pipeline" of commands:

hostname
cat /proc/self/cgroup | grep "docker" | sed 's/^.*\///' | tail -n 1

From the host system -> just ask docker to print out the current processes:

docker ps -a

From the host system, open another terminal and run the following command to commit the changes to the container. Make sure to replace the <container_id> with the actual container ID value:

sudo docker commit <container_id> ubuntu_czkawka

Clean up (DOCKER CONTAINER)

Now it's time to exit the container and stopping it. You will need to reuse the <container_id> just entered in the command above:

exit
sudo docker stop <container_id>

Mounting SAMBA shares (HOST SYSTEM)

At this point, on my host system I have the need to support Samba because I want czkawka to search for duplicates on my remote disks that are shared via Samba.If you don't have this same need, feel free to skip this step.

If you do have the need or you are simply interested in learning how to expose the Samba share from the host system to the docker container, then keep reading.

Take care of the SAMBA shares, substituting your values for <username>, <password>, <volume>, and <mount_point>:

sudo mkdir -p <mount_point>
sudo mount -t cifs -o username=<your_username>,password=<your_password> <volume> <mount_point>

Run the container (HOST SYSTEM)

At this point, every time you want to run czkawka you can run the following command to get the docker container going with the mapping of the SAMBA share available to the location of your choosing.

For the sake of this example, I have mapped the SAMBA share to /mnt/routerhdd:

sudo docker run -it -v /mnt/routerhdd:/mnt/routerhdd ubuntu_czkawka bash

Additionally, I decided to tag the docker image (container) with the actual version of czkawka that I built from source, so I can remember it later:

sudo docker commit <container_id> ubuntu_czkawka:<version>

Conclusion

Congratulations! You have now access to the latest version of czkawka even if your hardware is too told to support flatpack or snap. Find out more here on how to use it.