• This repository has been archived on 24/Nov/2019
  • Stars
    star
    308
  • Rank 134,841 (Top 3 %)
  • Language
  • License
    MIT License
  • Created over 6 years ago
  • Updated over 1 year ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Mine cryptocurrencies with Docker containers and get paid in Bitcoin (BTC)

mine-with-docker

This repository contains Docker images and Dockerfiles that let you get from zero to mining in around 5 minutes on any Linux host anywhere.

CPU mining can be profitable using algorithmns like: Cryptonight, Hodl or Equihash. Find out more about profitability here.

Disclaimer: this software is provided with no warranty. Use at your own risk. If you plan to mine on a cloud check the terms and conditions before you start. The same applies if you are using private equipment or an on-site datacenter for mining.

Tip: Mining will use all the CPU resources available on the machine so do not run it where you have critical applications.

How does it work?

Instead of mining BitCoin or other currencies on your own this software works by connecting your CPU / GPU to a mining pool. You get paid for the shares your computer makes towards solving a block. The NiceHash mining pool used in this example lets you mine using two dozen different algorithms and can tell you what is most profitable for your hardware.

  • What should I mine?

At time of writing a quad-core Intel CPU would be best mining Cryptonight, Hodl or Equihash.

  • How do I get a wallet?

You can sign-up for a wallet at blockchain.info or coinbase.com. When you create a wallet you can then click "receive funds" or similar to generate a new address for the wallet.

  • What is the barrier to entry?

There barrier to entry is super low - you just have to have a Linux system connected to the Internet where you can install Docker. That's it. You then run the image I've already built and start accruing Bitcoins.

  • Can I use my Raspberry Pi cluster?

Absolutely not.. there is no point even going there and believe me I've tried. You may find an obscure "alt coin" that can be mined with a Raspberry Pi but getting the money out of an obscure mining pool or exchange is more trouble than it's worth.

  • Is it profitable?

It can be profitable depending on your hardware and electricity costs. If you have a single node and can get paid 2-5USD / day for instance then that's going to equate to 60-150 USD / month. Now if you actually have 20 or 50 nodes you can apply a multiplier.

  • Where have you tested this?

Tested on cloud, but as I mentioned - check T&Cs before starting. You take full responsibility for any breach of T&Cs.

Own hardware:

  • MacBook Pro 13" touchbar i5
  • Intel Nuc i5 Gen 5
  • Dell Optiplex Intel i7
  • What is Docker?

Docker uses containers and immutable images to build and package software and all its dependencies. Read more here

Try my Hands-On Labs for Docker if you want to learn more.

Tip: If you have credits with a cloud provider or are using the Spot Instance market then this could be a way for you to generate some coin at a low cost.

Pre-reqs

We need to install Docker CE so that we can run a container. The container holds all the mining code and dependencies as a single immutable image. You can install with a single line using a utility script - I generally use this with Ubuntu, but other distributions are supported too.

  • Install Docker CE:
curl -sL https://get.docker.com | sh

If not running as a root user then you should look at the final message about using usermod to grant access to Docker to your user account. This may be something like usermod alexellis -aG docker

  • Setup Docker Swarm

We will be using Docker Swarm to control the container we're using for mining.

Type in the following:

docker swarm init

If this command complains about --advertise-addr - then pass --advertise-addr=127.0.0.1.

Start mining

Create a service and enter your bitcoin wallet ID:

  • Mine Hodl
docker service create --mode=global \
  --name miner alexellis2/cpu-opt:2018-1-2 ./cpuminer \
  -a hodl \
  -o stratum+tcp://hodl.usa.nicehash.com:3352 \
  -u 1M2KME8VBx24RsU3Ed2dEkF9EFghn3jR2o.cloud1
  • Mine Cryptonight
docker service create --mode=global \
  --name miner alexellis2/cpu-opt:2018-1-2 ./cpuminer \
  -a cryptonight \
  -o stratum+tcp://cryptonight.usa.nicehash.com:3355 \
  -u 1M2KME8VBx24RsU3Ed2dEkF9EFghn3jR2o.cloud1

You must replace "usa" with your location such as "hk" or "eu", read on.

Tip : If you are planning on using an Atom processor you will need to rebuild the image using the instructions below. Atom CPUs are not advised for mining.

  • Replace "1M2KME8VBx24RsU3Ed2dEkF9EFghn3jR2o" with your wallet ID and "cloud1" with the name of the host you're mining on if you want to track it.

  • If you live outside the EU then find your nearest Stratum proxy server from Nicehash and replace the eu URL with your nearest location.

  • If you're running the command for the second time then remove the service with: docker service rm miner

Limiting CPU usage

This is a community suggestion from @linuxjuggler.

If you want you can limit the CPU usage using the --limit-cpu option in the docker service create command.

Also its worth mentionining that you can limit the CPU core usage by selecting which cores to target via

docker run alexellis2/cpu-opt:2018-1-2 ./cpuminer --help:
      --cpu-affinity    set process affinity to cpu core(s), mask 0x3 for cores 0 and 1
      --cpu-priority    set process priority (default: 0 idle, 2 normal to 5 highest)

@linuxjuggler writes:

Limiting the amount of CPU or number of cores being used may mean you can continue to use the system for other purposes. It is also less likely to trigger a high CPU alert if you are running monitoring software.

Stop/pause mining

To pause mining type in docker service scale miner=0. To resume set the replicas to 1.

To completely stop mining use docker service rm miner

Rebuild the image

This is optional and not recommended for beginners.

If you need to rebuild the Docker image for updates or for a different CPU architecture/variation such as an Atom CPU:

git clone https://github.com/alexellis/mine-with-docker
cd mine-with-docker/cpu-opt
docker build -t cpu-opt:latest .

After rebuilding the image swap out alexellis2/cpu-opt:2018-1-2 for cpu-opt:latest or whatever you chose to call it in the docker build command.

Monitor your balance / workers

You can use the nicehash UI to monitor your balance and predicted payout. Mining pools generally wait until you reach a certain (low) balance before sending an automatic transfer to your wallet.

Here's an example with my donation address:

https://www.nicehash.com/miner/1M2KME8VBx24RsU3Ed2dEkF9EFghn3jR2o

Nicehash and many other mining pools have their own HTTP APIs where you can programatically query your hashing rate, balance and list of connected workers.

Tip: You can use different mining pools simply by adjusting the stratum URL passed in via the -o flag to the container.

Donate

You can follow me on Twitter @alexellisuk or make a donation with Bitcoin or Ethereum below:

Donate via:

  • BTC: 1M2KME8VBx24RsU3Ed2dEkF9EFghn3jR2o
  • Bitcoin Cash: 1M2KME8VBx24RsU3Ed2dEkF9EFghn3jR2o
  • ETH: 0x0D0c7108AD4180486E03B4Fc44AD794a209eCb37
  • LTC: LTt4VGXJMXALgzyjw6zACRxigNADaDYNH9

License

MIT

Copyright Alex Ellis 2017-2018

More Repositories

1

k3sup

bootstrap K3s over SSH in < 60s πŸš€
Go
5,267
star
2

arkade

Open Source Marketplace For Developer Tools
Go
3,546
star
3

awesome-baremetal

Bare-metal is awesome. Let's share our favourite tools.
1,424
star
4

k8s-on-raspbian

Kubernetes on Raspbian (Raspberry Pi)
Shell
881
star
5

docker-arm

Build Docker and Swarm on an ARM SoC like the Raspberry Pi
Shell
875
star
6

derek

Reduce maintainer fatigue by automating GitHub
Go
790
star
7

growlab

A global contest to grow and monitor your own food with Raspberry Pi
Python
441
star
8

HandsOnDocker

Get hands-on with Docker through a dozen self-paced and progressive labs.
C#
438
star
9

registry-creds

Replicate Kubernetes ImagePullSecrets to all namespaces
Go
306
star
10

jaas

Run jobs (tasks/one-shot containers) with Docker
Go
303
star
11

firecracker-init-lab

Build a Firecracker microVM from a container image
Shell
179
star
12

expressjs-k8s

Express.js microservice with a Dockerfile, Kubernetes YAMLs and a non-root user
JavaScript
165
star
13

run-job

Run a Kubernetes Job and get the logs when it's done πŸƒβ€β™‚οΈ
Go
162
star
14

spotminer

Golang automation for mining cryptocurrencies on the Spot Market
Go
161
star
15

docker-blinkt-workshop

Get into physical computing with Docker and Raspberry Pi
Python
152
star
16

go-execute

Automate CLI commands with Go
Go
134
star
17

ghost-on-docker

Ghost Blog on Docker - Dockerfile for ARM etc
Makefile
111
star
18

k8s-tls-registry

Setup a privateΒ Docker registry with TLS on Kubernetes
90
star
19

openfaas-puppeteer-template

OpenFaaS template for headless Chrome and Puppeteer
JavaScript
90
star
20

civo-fluxcd-expressjs

FluxCD and Express.js GitOps tutorial for Civo
82
star
21

hash-browns

Generate SHA256 hashes in Go with Prometheus metrics
Go
76
star
22

rodak

Build your own Rodak - portable Kodak Brownie powered by Raspberry Pi
Python
72
star
23

phototimer

A smart time-lapse driver for Raspberry Pi using raspistill
Python
69
star
24

leaderboard-app

GitHub leaderboard for your organisation or repo (Serverless SPA)
Go
67
star
25

raspberrypi-youtube-streaming

Stream straight to YouTube from your Raspberry Pi with Docker.
Shell
63
star
26

quickstart-prometheus

Quickstart for Prometheus
62
star
27

faas-containerd

containerd and CNI provider for OpenFaaS
Go
61
star
28

aspnet-voteservice

Windows Containers for Docker Voting App
JavaScript
60
star
29

helm3-expressjs-tutorial

Guide to Helm 3 with an Express.js microservice
58
star
30

cli-progress-animation

Coloured progress-bar for your Golang CLI
Go
56
star
31

swarmmode-tests

Series of test cases for Docker swarmmode
JavaScript
56
star
32

mongodb-function

OpenFaaS Function that makes use of a connection pool to access MongoDB
JavaScript
53
star
33

async-example

Asynchronous patterns in Node.js by example: async.waterfall/series/queue
JavaScript
52
star
34

href-counter

Golang multi-stage build to count links within a page for SEO
Go
52
star
35

faas-dockercon

Functions for Dockercon
JavaScript
49
star
36

tensorflow-serving-openfaas

Example of using TensorFlow Serving with OpenFaaS
Dockerfile
47
star
37

pizero-docker-demo

Live IoT cluster demonstration
Shell
46
star
38

jenkins2docker

Jenkins 2.x recipe with docker-compose
44
star
39

enviro-dashboard

Environmental monitoring (with Raspberry Pi sensors) and InfluxDB/Grafana
Python
43
star
40

blinkt_go_examples

The beginning of Blinkt examples programs in Go
Go
37
star
41

funker-dispatch

An API Gateway for serverless functions on Docker Swarm (deprecated, see: openfaas.com)
JavaScript
37
star
42

pi_zero_stock

PI Zero Stock tracker in Node.js with Redis back-end to cache results
HTML
36
star
43

minio-gauge

A Minio pressure gauge with the Raspberry Pi and Blinkt! from Pimoroni, see in real-time how busy your S3 cloud storage is
Python
36
star
44

dockerlabs

Moved to Hands On Docker, click for details.
35
star
45

sponsors-functions

GitHub Sponsors webhook receiver and Discord forwarder
JavaScript
33
star
46

openfaas-streaming-templates

Stream data from ffmpeg/Node.js/Bash over HTTP with OpenFaaS
Dockerfile
32
star
47

fstail

Scan a directory for changed files and tail them
Go
32
star
48

upload-assets

GitHub Action to upload multiple assets to a release
JavaScript
31
star
49

twitter-bots

Learn to create Twitter bots by example.
JavaScript
30
star
50

kubernetes-todo-go-app

A TODO API for Kubernetes written in go
Go
30
star
51

blinkt_go

A Golang library for the Pimoroni Blinkt!
Go
28
star
52

sshdkit

Example for building a bootable SSHD system with LinuxKit
Shell
28
star
53

crud-postgresql-nodejs-openfaas

Build a CRUD API with Postgresql and Node.js with OpenFaaS
28
star
54

gumroad-custom-workflow

Get webhooks in Slack every time you sell a product on Gumroad
JavaScript
27
star
55

seeds2

A Python application for live tweeting photos of your seeds growing on your Raspberry Pi.
Python
26
star
56

iot-sensors-mqtt-openfaas

Collect, plot and analyse sensor readings from your IoT devices with OpenFaaS
Python
26
star
57

hmac

Validate hmac signatures in Go
Go
26
star
58

2020

Make your own 2020 ASCII art
JavaScript
26
star
59

minikube-operator

An operator for Minikube - Kubernetes on Kubernetes
Go
25
star
60

function-storage-example

Serverless Functions storage tutorial with Minio and OpenFaaS
Python
25
star
61

inlets-connect

A tiny HTTP CONNECT proxy 🚦
Go
23
star
62

guidgenerator-aspnet

Build and deploy an ASP.NET WebAPI application with traditional .NET on Windows with Docker
JavaScript
23
star
63

containerd-arm

Arm64 & armhf binaries of containerd
22
star
64

faas-twitter-fanclub

Serverless polaroids - posted to Twitter for GitHub stars
Python
22
star
65

inlets-heroku-tutorial

Run inlets on Heroku to tunnel local endpoints for free
Dockerfile
21
star
66

mkaas

mkaas: minikube on Kubernetes with CRDs
Go
21
star
67

datacenter-sensor

Sensors for the datacenter to protect against intruders and high temperatures
JavaScript
20
star
68

windowscontainers-jenkinsci

Windows Containers PoC for Server Core
20
star
69

repaint-the-past

Full instructions for repainting the past
Python
19
star
70

nicehash-overwatch

Keep an eye on your stats with the Nicehash mining pool
JavaScript
19
star
71

zumopi

Zumo robot control code for Raspberry PI and Wiimote
Python
18
star
72

comment-vibes

OpenFaaS CRUD sample with a Postgres backend and GitHub emojis as input.
Go
16
star
73

alexa-demos

Series of demos for the Amazon Alexa service
JavaScript
14
star
74

alexa-blinkt

JavaScript
14
star
75

tinkerbot

ChatOps for Tinkerbell
Go
13
star
76

PlanningPoker

PlanningPoker for estimating story points in SCRUM
HTML
13
star
77

mqtt-to-s3

mqtt-s3-example
Python
13
star
78

express-middleware-sinon

Express middleware with Sinon testing
JavaScript
13
star
79

lambda-on-openfaas-poc

A PoC for running Lambda functions unmodified on OpenFaaS
Go
12
star
80

multiarch-templates

Multi-arch templates for OpenFaaS
JavaScript
12
star
81

workflow-yaml-template

Rudimentary YAML workflow runner for OpenFaaS
Go
12
star
82

minty

Minting OIDC tokens from GitHub Actions for use with OpenFaaS
Go
11
star
83

release-it

CI example from Everyday Golang
Makefile
10
star
84

goto

My URL shortener
JavaScript
10
star
85

github_counter_faas

Example FaaS stack for Raspberry Pi (ARM) to integrate with Github events.
Python
10
star
86

webhook-tester

I just use this repo for testing Github integrations.
JavaScript
9
star
87

motephat-alexa

Control Pimoroni's (Mote) homelighting kit for the Raspberry Pi through the Alexa Skills kit
Python
9
star
88

eyes-in-the-sky

Instructions and Dockerfiles for tracking flights with your Raspberry Pi and a USB TV stick.
9
star
89

php7-swoole-template

OpenFaaS PHP7 template using Swoole
PHP
9
star
90

bulk-twitter-follow

Follow a bulk list of people on Twitter using the API
Python
9
star
91

restic-minio-civo-learn-guide

Backup your data using Restic, Minio, and Civo
9
star
92

locust-openfaas

Locust load-testing tool on OpenFaaS
Python
8
star
93

kubecon-blog

My blog about my KubeCon talk, also my demo
Go
8
star
94

captains-list

Gives a list of Docker Captain Twitter handles
HTML
8
star
95

mailbox

mailbox: a dead-letter queue for NATS Streaming
Go
8
star
96

arkade-get

Get all the CLIs you need from arkade for a GitHub Action
JavaScript
8
star
97

updateip

Update your Namecheap external IP with Dynamic DNS
Go
8
star
98

scroll-phat-node

Work-in-progress node.js library for Pimorani's scrollPhat
JavaScript
8
star
99

pimeter

Smart energy usage meter for Raspberry PI
JavaScript
7
star
100

static-site-template

Static site template with OpenFaaS and Nginx
Dockerfile
7
star