One week ago we published our Monero Mining Benchmarks: CPU Mining With Select Dual Intel Xeon E5 Systems article. At the end of that article, and in the STH forums we posted a quick how-to instruction guide for using Docker on Ubuntu Linux, CentOS or any other Linux operating system and mining Monero. In the past week since we published that article, we have now had over 50,000 pulls from our Docker hub repository which is an amazing response. Today we are going to have our formal guide on running the Docker-based CPU miner.
The Quick Monero Background
At the turn of 2017, and for the past several years, Bitcoin has been the largest cryptocurrency by far. Monero is a cryptocurrency that put an emphasis on privacy and is considered significantly more anonymous than Bitcoin. As a result, Monero has moved from a $0.50 / 1 XMR currency a year ago to $12.50/ 1 XMR as of today. That movement, and the privacy focus, has made Monero a top 5 cryptocurrency and pushed it into the mainstream with even a recent WIRED article on the currency.
The advantage of this has been that Monero is now very easy to exchange and has tools that are more mature than several other cryptocurrencies. For STH readers there is a larger implication. Unlike Bitcoin mining which is dominated by ASICs, Monero is currently best mined on GPUs. CPU mining can be profitable as well. That means STH readers have the infrastructure able to mine Monero.
CPU Mining with Monero and Docker
There are hundreds of questions out there on how to mine Monero with CPUs and various Linux distributions. Docker and our pre-made container makes that ridiculously simple. There is no more dependency hunting, build troubleshooting, or other work. Just a simple command to run the popular Wolf’s CPU miner.
Just to give you an idea of how easy this is to setup and use, within 8 days we rocketed past 50K Docker Hub pulls on our minergate image.
We did account for a few dozen of these pulls when we deployed it using Docker Swarm on our test cluster.
Step 0: Install Docker (if it is not already)
If you want to install Docker you can either use your standard package manager or the company makes a one-liner install script that works on most platforms. Installing anything downloaded directly is dangerous so use this at your own risk:
wget -qO- https://get.docker.com/ | sh
You will also likely want to use the usermod -aG command at the end of the installation script so you can use Docker without having to sudo every time. If you do not, you can just append sudo to the start of the following commands.
Step 1: Determine a Pool and Get a Wallet
We recommend mining in a pool to get started. If you want to mine in a pool, some of the more popular are minergate and moneropool. With Minergate, you can simply sign-up and start mining using an e-mail address (even a throw-away one.) Using other pools like moneropool you will want to get a wallet. Perhaps the easiest way to get a wallet is using MyMonero. If you are using Minergate, XMR will be stored with your account so you do not technically need another wallet.
Step 2: Start Mining
The final step in the process is to start mining. Here is the command you can use to do CPU mining on your Docker server using the Minergate pool:
docker run -itd -e email@example.com servethehome/monero_cpu_minergate
Replace firstname.lastname@example.org with your Minergate username. We do not take any shares for using our image but we do appreciate using the STH affiliate link when you sign up.
If you want to use Moneropool there is a very similar command:
docker run -itd -e email@example.com servethehome/monero_cpu_moneropool
Here you should replace firstname.lastname@example.org with your Monero wallet address. Likewise if you want to use xmrpool.net:
docker run -itd -e email@example.com servethehome/monero_cpu_xmrpooldotnet
Again replacing your wallet address for firstname.lastname@example.org.
We are using -itd to launch the Docker containers but you can instead use simply -d. We assume most getting started with Docker will be interested in their performance which is why the commands above will print information to the console.
After the username you can override and set the number of threads you want to use by adding a numthreads environment variable. For example, if you wanted to use only 12 cores in a system:
docker run -itd -e email@example.com -e numthreads=12 servethehome/monero_cpu_minergate
That will allow you to run these images alongside other applications.
That is it! With any of the above one-liners you can mine Monero on a Docker host using a single command. We created these containers, and are using Wolf’s miner specifically so they are easy to deploy across a Docker Swarm. You can even use web management tools like Portainer and Rancher to deploy these as low priority containers across entire clusters within seconds.
We also have NVIDIA GPU miners we run with nvidia-docker that you can read about following that link. If you have any issues getting started or just want to chat with a community using this, head over to the STH forums. If you are sick of reading Docker how-to guides with do-nothing nginx containers, this is also a great way to learn Docker and earn a few dollars in the process. The vision of this is to use excess server compute capacity and data center power (e.g. power that is being paid for but unused) to earn a healthy cost recovery stream.