Skip to content

Latest commit

 

History

History
185 lines (135 loc) · 4.78 KB

README.md

File metadata and controls

185 lines (135 loc) · 4.78 KB

HashR in docker

Follow these steps to set-up HashR running in a docker container.

If you want a local installation, check these steps.

Table of contents

HashR docker image

You can either use our hosted docker image or build it yourself.

Pull the HashR image

The HashR docker image will provide the HashR binary and tools it needs to work.

By default the latest tagged release will be pulled if not specified otherwise:

docker pull us-docker.pkg.dev/osdfir-registry/hashr/release/hashr

Pulling a specific release tag:

docker pull us-docker.pkg.dev/osdfir-registry/hashr/release/hashr:v1.7.1

Build the HashR image

From the repository root folder run the following command:

docker build -f docker/Dockerfile .

Setup a database and importers

Database

You still need to provide your own database for HashR to store the results. Check the Setting up storage for processing tasks step in the local installation guide.

Importers

Follow the Setting up importers guide to setup the importers you want to use.

Come back here for running HashR in docker with specific importers.

Docker networking

Create a docker network that will be used by hashr_postgresql and the hashr container.

docker network create hashr_net
docker network connect hashr_net hashr_postgresql

Run HashR

Get all availalbe HashR flags

docker run us-docker.pkg.dev/osdfir-registry/hashr/release/hashr -h

Examples

NOTE Ensure that the host directory mapped into /data/ in the container is readable for all!

Run HashR using the iso9660 importer and export results to PostgreSQL:

docker run -it \
  --privileged \
  --network hashr_net \
  -v ${pwd}/ISO:/data/iso \
  us-docker.pkg.dev/osdfir-registry/hashr/release/hashr \
  -storage postgres \
    -postgres_host hashr_postgresql \
    -postgres_port 5432 \
    -postgres_user hashr \
    -postgres_password hashr \
    -postgres_db hashr \
  -importers iso9660 \
    -iso_repo_path /data/iso/ \
  -exporters postgres

Run HashR using the deb importer and export results to PostgreSQL:

docker run -it \
  --network hashr_net \
  -v ${pwd}/DEB:/data/deb \
  us-docker.pkg.dev/osdfir-registry/hashr/release/hashr \
  -storage postgres \
    -postgres_host hashr_postgresql \
    -postgres_port 5432 \
    -postgres_user hashr \
    -postgres_password hashr \
    -postgres_db hashr \
  -importers deb \
    -deb_repo_path /data/deb/ \
  -exporters postgres

Run HashR using the GCPimporter and export results to PostgreSQL:

docker run -it \
  --network hashr_net \
  -v ${pwd}/hashr-sa-private-key.json:/creds/hashr-sa-private-key.json \
  -e GOOGLE_APPLICATION_CREDENTIALS='/creds/hashr-sa-private-key.json' \
  us-docker.pkg.dev/osdfir-registry/hashr/release/hashr \
  -storage postgres \
    -postgres_host hashr_postgresql \
    -postgres_port 5432 \
    -postgres_user hashr \
    -postgres_password hashr \
    -postgres_db hashr \
  -importers GCP \
    -gcp_projects debian-cloud,centos-cloud,rhel-cloud \
    -hashr_gcp_project <GCP PROJECT> \
    -hashr_gcs_bucket <GCS BUCKET> \
  -exporters postgres

Debugging

Here are some known issues that you can run into when using HashR with docker.

Folder: permission denied

If you get a permission error from HashR when working with docker volumes ensure that the folder you are mapping into the container has the same group id as the HashR group inside the container. Most likely this will be the 1000. To change the group, run:

sudo chown -R :1000 <DIR>

mount: permission denied

Some importers need to mount the provided file (e.g. ISO files). This is not supported inside the docker container by default. To workaround this issue, use the --privileged flag with your docker run command.

Debugging inside the container

To debug problems inside the HashR container start an interactive shell like with the following command:

docker run -it \
  --network hashr_net \
  --entrypoint=/bin/bash \
  us-docker.pkg.dev/osdfir-registry/hashr/release/hashr

Logging output

For debugging purposes you can send logging output to stderr by using the ---logtostderr=1 flag.

General hashr logs its output to /tmp/hashr.INFO.