{"id":13449219,"url":"https://github.com/alexellis/mine-with-docker","last_synced_at":"2025-03-22T22:32:15.683Z","repository":{"id":87753947,"uuid":"115994889","full_name":"alexellis/mine-with-docker","owner":"alexellis","description":"Mine cryptocurrencies with Docker containers and get paid in Bitcoin (BTC)","archived":true,"fork":false,"pushed_at":"2018-02-06T22:13:04.000Z","size":30,"stargazers_count":317,"open_issues_count":6,"forks_count":67,"subscribers_count":22,"default_branch":"master","last_synced_at":"2024-10-28T16:44:19.890Z","etag":null,"topics":["bootstrap","docker","mining","nicehash","swarm"],"latest_commit_sha":null,"homepage":"https://www.alexellis.io/","language":null,"has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/alexellis.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null}},"created_at":"2018-01-02T08:52:59.000Z","updated_at":"2024-09-29T19:37:03.000Z","dependencies_parsed_at":null,"dependency_job_id":"5f69a97f-ba2d-4e6c-988a-564187583744","html_url":"https://github.com/alexellis/mine-with-docker","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alexellis%2Fmine-with-docker","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alexellis%2Fmine-with-docker/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alexellis%2Fmine-with-docker/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alexellis%2Fmine-with-docker/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/alexellis","download_url":"https://codeload.github.com/alexellis/mine-with-docker/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245028943,"owners_count":20549623,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["bootstrap","docker","mining","nicehash","swarm"],"created_at":"2024-07-31T06:00:33.575Z","updated_at":"2025-03-22T22:32:15.441Z","avatar_url":"https://github.com/alexellis.png","language":null,"funding_links":[],"categories":["Others"],"sub_categories":[],"readme":"mine-with-docker\n=================\n\nThis repository contains Docker images and Dockerfiles that let you get from zero to mining in around 5 minutes on any Linux host anywhere.\n\nCPU mining can be profitable using algorithmns like: Cryptonight, Hodl or Equihash. Find out more about [profitability here](https://www.nicehash.com/profitability-calculator).\n\nDisclaimer: 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.\n\n\u003e Tip: Mining will use all the CPU resources available on the machine so do not run it where you have critical applications.\n\n## How does it work?\n\nInstead 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.\n\n* What should I mine?\n\nAt time of writing a quad-core Intel CPU would be best mining Cryptonight, Hodl or Equihash.\n\n* How do I get a wallet?\n\nYou can sign-up for a wallet at [blockchain.info](https://blockchain.info) or [coinbase.com](https://www.coinbase.com/). When you create a wallet you can then click \"receive funds\" or similar to generate a new address for the wallet.\n\n* What is the barrier to entry?\n\nThere 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.\n\n* Can I use my Raspberry Pi cluster?\n\nAbsolutely 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.\n\n* Is it profitable?\n\nIt 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.\n\n* Where have you tested this?\n\nTested on cloud, but as I mentioned - check T\u0026Cs before starting. You take full responsibility for any breach of T\u0026Cs.\n\nOwn hardware:\n\n- MacBook Pro 13\" touchbar i5\n- Intel Nuc i5 Gen 5\n- Dell Optiplex Intel i7\n\n* What is Docker?\n\nDocker uses containers and immutable images to build and package software and all its dependencies. [Read more here](https://www.docker.com/what-docker)\n\nTry my [Hands-On Labs for Docker](https://github.com/alexellis/HandsOnDocker/blob/master/Labs.md) if you want to learn more.\n\n\u003e 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.\n\n## Pre-reqs\n\nWe 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](https://www.docker.com/community-edition).\n\n* Install Docker CE:\n\n```\ncurl -sL https://get.docker.com | sh\n```\n\n\u003e 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`\n\n* Setup Docker Swarm\n\nWe will be using Docker Swarm to control the container we're using for mining.\n\nType in the following:\n\n```\ndocker swarm init\n```\n\n\u003e If this command complains about `--advertise-addr` - then pass `--advertise-addr=127.0.0.1`.\n\n## Start mining\n\nCreate a service and enter your bitcoin wallet ID:\n\n* Mine Hodl\n\n```\ndocker service create --mode=global \\\n  --name miner alexellis2/cpu-opt:2018-1-2 ./cpuminer \\\n  -a hodl \\\n  -o stratum+tcp://hodl.usa.nicehash.com:3352 \\\n  -u 1M2KME8VBx24RsU3Ed2dEkF9EFghn3jR2o.cloud1\n```\n\n* Mine Cryptonight\n\n```\ndocker service create --mode=global \\\n  --name miner alexellis2/cpu-opt:2018-1-2 ./cpuminer \\\n  -a cryptonight \\\n  -o stratum+tcp://cryptonight.usa.nicehash.com:3355 \\\n  -u 1M2KME8VBx24RsU3Ed2dEkF9EFghn3jR2o.cloud1\n```\n\n**You must replace \"usa\" with your location such as \"hk\" or \"eu\", read on.**\n\n\u003e 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.\n\n* Replace \"1M2KME8VBx24RsU3Ed2dEkF9EFghn3jR2o\" with your wallet ID and \"cloud1\" with the name of the host you're mining on if you want to track it.\n\n* If you live outside the EU then find your [nearest Stratum proxy server from Nicehash](https://www.nicehash.com/asic-mining) and replace the `eu` URL with your nearest location.\n\n* If you're running the command for the second time then remove the service with: `docker service rm miner`\n\n## Limiting CPU usage\n\nThis is a community suggestion from @linuxjuggler. \n\n\nIf you want you can limit the CPU usage using the `--limit-cpu` option in the `docker service create` command.\n\nAlso its worth mentionining that you can limit the CPU core usage by selecting which cores to target via \n\n```\ndocker run alexellis2/cpu-opt:2018-1-2 ./cpuminer --help:\n      --cpu-affinity    set process affinity to cpu core(s), mask 0x3 for cores 0 and 1\n      --cpu-priority    set process priority (default: 0 idle, 2 normal to 5 highest)\n```\n\n@linuxjuggler writes:\n\n\u003e 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.\n\n## Stop/pause mining\n\nTo pause mining type in `docker service scale miner=0`. To resume set the replicas to `1`.\n\nTo completely stop mining use `docker service rm miner`\n\n## Rebuild the image\n\nThis is optional and not recommended for beginners.\n\nIf you need to rebuild the Docker image for updates or for a different CPU architecture/variation such as an Atom CPU:\n\n```\ngit clone https://github.com/alexellis/mine-with-docker\ncd mine-with-docker/cpu-opt\ndocker build -t cpu-opt:latest .\n```\n\nAfter 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.\n\n## Monitor your balance / workers\n\nYou 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.\n\nHere's an example with my donation address:\n\n```\nhttps://www.nicehash.com/miner/1M2KME8VBx24RsU3Ed2dEkF9EFghn3jR2o\n```\n\nNicehash and many other mining pools have [their own HTTP APIs](https://www.nicehash.com/doc-api) where you can programatically query your hashing rate, balance and list of connected workers.\n\n\u003e Tip: You can use different mining pools simply by adjusting the stratum URL passed in via the `-o` flag to the container.\n\n\n## Donate\n\nYou can follow me on Twitter [@alexellisuk](https://twitter.com/alexellisuk) or make a donation with Bitcoin or Ethereum below:\n\nDonate via:\n\n* BTC: 1M2KME8VBx24RsU3Ed2dEkF9EFghn3jR2o\n* Bitcoin Cash: 1M2KME8VBx24RsU3Ed2dEkF9EFghn3jR2o\n* ETH: 0x0D0c7108AD4180486E03B4Fc44AD794a209eCb37\n* LTC: LTt4VGXJMXALgzyjw6zACRxigNADaDYNH9\n\n## License\n\nMIT\n\nCopyright Alex Ellis 2017-2018\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Falexellis%2Fmine-with-docker","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Falexellis%2Fmine-with-docker","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Falexellis%2Fmine-with-docker/lists"}