Skip to content

Instantly share code, notes, and snippets.

@tarfeef101
Last active March 9, 2021 05:26
Show Gist options
  • Save tarfeef101/1721dfabf0a2d6c559925b0b9f2d31a0 to your computer and use it in GitHub Desktop.
Save tarfeef101/1721dfabf0a2d6c559925b0b9f2d31a0 to your computer and use it in GitHub Desktop.
Dockerized Ethminer for Nicehash (CUDA)
This file exists because of how naming gists works in GitHub. This system needs to be improved, a lot.

Purpose

This is a simple setup to mine ethereum for nicehash within docker on a linux host. The docker container runs the miner using the nvidia-docker runtime to allow for cuda usage, and the script+crontab ensure it stays running. The latter is necessary because sometimes the miner encounters errors but will not exit, so restart: on-failure is insufficient.

Usage

To use, enter your address and worker name in the docker-compose.yaml, put the crontab into your crontab, and the script in the correct location. Ensure the base image for your Dockerfile matches the CUDA version on the host. Last, you want to download and extract the latest release of ethminer and place the ethminer executable and kernels folder in the working directory when building the Dockerfile. This keeps the image size down by not including the deps needed to do so within the container.

#!/bin/bash
util=$(nvidia-smi -q -d UTILIZATION | awk '/Gpu/ { print $3 }')
if [ $util -lt 80 ]; then
echo "restarting container"
cd /extra/mining/bin
/usr/local/bin/docker-compose restart
else
echo "continuing"
fi
* * * * * /path/to/cron.sh >> /path/to/script.log 2>&1
version: "3"
services:
mining:
image: tarfeef101/ethminer
build: .
restart: on-failure
logging:
driver: "json-file"
options:
max-size: "200k"
max-file: "1"
environment:
- ADDRESS=PLACEHOLDER
- WORKER=PLACEHOLDER
FROM nvidia/cuda:11.0-runtime-ubuntu18.04
COPY ethminer /opt/ethminer
COPY kernels /opt/kernels/
CMD /opt/ethminer -U -P stratum2+tcp://$ADDRESS.$WORKER@daggerhashimoto.usa.nicehash.com:3353
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment