I finally got hashcat running on Docker, with GPU support for NVIDIA cards. First, I needed to install Docker and NVIDIA Container Toolkit on my system, and add my user to the docker group.
root $ pacman -S --needed docker nvidia-container-toolkit
root $ systemctl enable --now docker.service
root $ usermod -aG docker user
Then I created a Dockerfile to set up the hashcat environment with NVIDIA support (using a BlackArch image):
FROM blackarchlinux/blackarch:latest
RUN pacman -Syu --noconfirm && \
pacman -S --noconfirm \
blackarch/cracken \
blackarch/pack \
blackarch/pipal \
extra/hashcat \
extra/hashcat-utils
RUN mkdir -p /etc/OpenCL/vendors && \
echo "libnvidia-opencl.so.1" > /etc/OpenCL/vendors/nvidia.icd
RUN mkdir /cracking
Then I created a docker-compose.yml
file to define the BlackArch container with hashcat installed.
services:
hashcat:
build:
context: .
dockerfile: Dockerfile
container_name: hashcat
working_dir: /cracking
volumes:
- /path/on/host/cracking:/cracking
deploy:
resources:
reservations:
devices:
- driver: nvidia
count: all
capabilities:
- gpu
networks: {}
Now I can build the Docker image and run hashcat:
user $ docker-compose build
user $ docker compose run --rm hashcat hashcat -I