Giter Site home page Giter Site logo

alexellis / mine-with-docker Goto Github PK

View Code? Open in Web Editor NEW
315.0 22.0 69.0 30 KB

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

Home Page: https://www.alexellis.io/

License: MIT License

bootstrap mining docker swarm nicehash

mine-with-docker's Introduction

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

mine-with-docker's People

Contributors

alexellis avatar dezren39 avatar zaherg avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

mine-with-docker's Issues

"docker service logs -f astronaut-finder" cannot get logs

When i run "docker service logs -f astronaut-finder", there is an error message "no such task or service: astronaut-finder".
Then I try "kubectl logs", it works
# kubectl logs astronaut-finder-7cddb4c595-2s2cm --namespace=openfaas-fn

2018/09/28 08:45:36 Version: 0.9.4      SHA: e67811c91c006dfe86feb945c88b0738ddf33a67
2018/09/28 08:45:36 Read/write timeout: 5s, 5s. Port: 8080
2018/09/28 08:45:36 Writing lock-file to: /tmp/.lock
2018/09/28 09:13:47 Forking fprocess.
2018/09/28 09:13:47 Query  
2018/09/28 09:13:47 Path  /
Oleg Artemyev
Oleg Artemyev is in space
2018/09/28 09:13:48 Duration: 1.407070 seconds

kubectl version as follws:

Client Version: version.Info{Major:"1", Minor:"10", GitVersion:"v1.10.5", GitCommit:"32ac1c9073b132b8ba18aa830f46b77dcceb0723", GitTreeState:"clean", BuildDate:"2018-06-21T11:46:00Z", GoVersion:"go1.9.3", Compiler:"gc", Platform:"linux/amd64"}
Server Version: version.Info{Major:"1", Minor:"10", GitVersion:"v1.10.5", GitCommit:"32ac1c9073b132b8ba18aa830f46b77dcceb0723", GitTreeState:"clean", BuildDate:"2018-06-21T11:34:22Z", GoVersion:"go1.9.3", Compiler:"gc", Platform:"linux/amd64"}

verify: Detected task failure

Just ran this on my swarm 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 <wallet>.crypto-1

But getting a verify: Detected task failure message

overall progress: 0 out of 1 tasks
p4p7u7r7z7pp: ready     [======================================>            ]
verify: Detected task failure

It keeps looping like that. Any clear issues?

cryptonightv7 ?

docker service create --mode=global
--name miner alexellis2/cpu-opt:2018-1-2 ./cpuminer
-a cryptonightv7
-o stratum+tcp://cryptonightv7.eu.nicehash.com:3363
-u walletid.cloud

does not work what is wrong here?

(Potential) issue with cryptonight

Hi, I am playing around with this repo and I had a quick question on whether something wasn't working.

I mined a bit with hodl and that seemed to work fine, the nicehash link showed my production and everything.

I switched over to try CryptoNite and it no longer seems to show an Accepted or Rejected speed rate. I can see it as an Active worker on nicehash, but it just doesn't seem to be accumulating any BTC

When I look at the container logs I can see it mining fine
[2018-01-13 20:56:44] CPU #5: 6 H, 39.31 H/s [2018-01-13 20:56:44] CPU #6: 6 H, 35.42 H/s [2018-01-13 20:56:44] CPU #0: 6 H, 36.84 H/s [2018-01-13 20:56:44] CPU #4: 6 H, 36.87 H/s [2018-01-13 20:56:44] CPU #3: 7 H, 39.66 H/s [2018-01-13 20:56:44] CPU #7: 7 H, 39.89 H/s [2018-01-13 20:56:44] CPU #2: 7 H, 39.26 H/s [2018-01-13 20:56:44] CPU #1: 6 H, 36.45 H/s
but I notice I don't see any Accepted logs. Anything I may be doing wrong?

Thanks in advance and let me know if you need further clarification

Run with a GPU server

First of all thanks for a great resource! Worked for me without a hitch!

Your docker image seems to be written for multicore CPU machines and not for GPUs. Is that correct?
Can you guide me a bit on how can I make it work with my Nvidia Titan X workstation?

Issues Running

I am somewhat new to this and am seeing this status on my Ubuntu server when running:

image

Any ideas? Nothing crazy in the logs that I can see. I did try rebuilding the image to see if that worked, hence the latest.

stratum_recv_line failed

i have successfully mined for a few hours. After a while, some errors ocasionally occurring. Now mining can not start because of this stratum_recv_line failed error.

docker service create --mode=global \
  --name miner alexellis2/cpu-opt:latest ./cpuminer \
  -a cryptonight \
  -o stratum+tcp://cryptonight.br.nicehash.com:3355 \
  -u mywallet.myworker

Connectivity question

Here I'm mining on few servers. I see two different issues.

Civo

docker ps - It runs

screen shot 2018-01-03 at 10 38 03 am

docker service logs miner - I see these issues in the logs

screen shot 2018-01-03 at 10 36 52 am

Packet

docker ps - It does not run at all

screen shot 2018-01-03 at 10 39 52 am

docker service logs miner - I see these issues in the logs

screen shot 2018-01-03 at 10 41 45 am

Scaleway

same issue as packet

Question

Any idea about how to debbug this?
Cheers!

Error: This node is not a swarm manager

I'm trying to run this container as the readme states, but

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 39eAUTFxjv7TZVBienbm3kNjmNGCRrAMdT.cloud2

However, I get the following error on ubuntu

Error response from daemon: This node is not a swarm manager. Use "docker swarm init" or "docker swarm join" to connect this node to swarm and try again.

Question

Just out of curiosty, why does a raspberry pi cluster not work?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.