Monero Mining on Linux made easy with Docker

25
Monero File
Monero File

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

Monero Logo With Xeon E5 Series
Monero Logo With Xeon E5 Series

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.

Monero Docker Hub Pulls
Monero Docker Hub Pulls as of 2017-02-08

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 username=example@example.com servethehome/monero_cpu_minergate

Replace example@example.com 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 username=example@example.com servethehome/monero_cpu_moneropool

Here you should replace example@example.com with your Monero wallet address. Likewise if you want to use xmrpool.net:

docker run -itd -e username=example@example.com servethehome/monero_cpu_xmrpooldotnet

Again replacing your wallet address for example@example.com.

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 username=example@example.com -e numthreads=12 servethehome/monero_cpu_minergate

That will allow you to run these images alongside other applications.

Final Words

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.

Portainer Global Service Detail Monero Mining
Portainer Global Service Detail Monero Mining

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.

25 COMMENTS

  1. I have followed this tutorial on two separate VMs (one Ubuntu 14.04 and one CentOS 7)… in both cases using the moneropool option with the wallet I created at my monero…. when I do the docker run command I get a hash back and then returned to the command line… but it doesn’t seem to actually be doing anything… my CPU usage is nothing… what am I missing?

    Thank you!

  2. Im getting the same thing here also just a hash back ..

    Unable to find image ‘servethehome/monero_cpu_minergate:latest’ locally
    latest: Pulling from servethehome/monero_cpu_minergate
    16da43b30d89: Pull complete
    1840843dafed: Pull complete
    91246eb75b7d: Pull complete
    7faa681b41d7: Pull complete
    97b84c64d426: Pull complete
    aa8b352289ff: Pull complete
    91de818e9e96: Pull complete
    9057c7b41e21: Pull complete
    6476d0b43646: Pull complete
    59e2488c0aa1: Pull complete
    Digest: sha256:7b42fda3e8f09b303a97ff75aba1c7a5b1c78b4ee22a1828928dcc70bc39e95c
    Status: Downloaded newer image for servethehome/monero_cpu_minergate:latest

  3. @Campos you only downloaded the Docker image. You now need to run the container. Look at the docker file and it gives you and example of the command.

    ex: $ docker run kannix/monero-miner -a cryptonight -o stratum+tcp://mine.moneropool.com:3333 -u 4AsZFFoMcNQF6sBWQL9zT3AmUkxGtcrGTKePCcamDZ9kBMZPEbPoTaT6TTnnY988HPJi3uybVtkWcHwixuAydwdD8MsqsWU -p x –threads 2

    Obviously replace the wallet address with your own.

    After you run the container, run:
    1. $ docker ps (this lets you see running containers on your machine)
    2. $ docker logs -f elated_montalcini (the elated_montalcini is the container name that you get after running docker ps. This will let you see the logs of the running container to see that it’s working and what your hash rate is. That’s it!

  4. Everything seems okay but it doesn’t display individual hashrate like it does if ran via any miner.
    Is there any way to see what hashrate my machine with docker container is pulling because Minergate only disply hashrate of all workers.

  5. Thanks for the heads up.
    Any way I can limit the number of cpu cores it uses.
    My current cpu usage is around 790%.

  6. In a multi GPU system, what would the best way be to allow simultaneous crypto mining and deep learning to maximize use of all the available GPU computing power?

  7. I followed the above instructions to the letter and it get an error saying “invalid reference format”

  8. Fred that is the right question. Stay tuned to STH but we are using nvidia-docker.

    Ray – need more info on configuration. Post in the STH forums crypto mining forum and someone will be able to help.

  9. Patrick,
    Thanks for the tutorial – I found it easy to follow. I have been running “docker run -itd -e username={wallet_address} servethehome/monero_cpu_moneropool” but haven’t seen anything in my wallet. How do I check the status or progress of the mining for my wallet? The docker log shows –
    accepted: 272/272 (100.00%), 36.39 H/s at diff 25000.1 (yay!!!)
    Stratum detected new block
    Stratum detected new block

  10. Hi Ken, you can see payouts via the pool UI. Many pools require a minimum amount before they payout to your wallet. We also have a great community in the STH forums that can help you optimize your mining.

  11. I’ve a system where monero_cpu_minergate only creates 4 monero threads out of 64 possible. I appreciate the “background” mode, but is there a way to run full on? Some command line, compile, or environment option that lets us choose the number of monero threads to run?

  12. Multiple systems from and old Xeon Westmere, to Epyc 7601s Patrick, why would a command line override care?

    The 64 core system has an Epyc 7601, thats 64M of L3, so the algorithm should be setting up for at least 16 threads right?

    (Oh and this web site has a HIGHLY annoying way of occasionally refreshing the page and LOOSING everything we’ve typed in, and can refuse to accept new comments late at night.)

  13. Yes, I’ve seen sub-numa clustering improve certain loads (if available and enabled in a BIOS). Still, with a recompile, why are separate containers needed?

    I do very much like the container approach tho, good work!

  14. Hi, thanks for setting this up. For xmrpool, you need a username (which is the wallet address) and a password (which tends to be a email address), from what I can tell there is no flag for the password when the docker container is run. Is this a preset value from the container? Thanks again 🙂

  15. right on, man! Worked perfectly!
    would put a screen shot of the miners working, but it won’t paste
    spun up a cheap ec2 to test, now can now scale this baby!

  16. So, is it profitable to join mining pools with low-spec hardware? I’m just starting on this subject and I’m looking for effective ways of mining Monero.

  17. @coinImp, I’m wondering the same. I’ve been trading cryptos for years but now wish to enter mining some. I have a cluster of 5 servers all with dual Xeon 2.8GHz processors but they are i686 class meaning that they typically only support 32bit software. Finding mining software for Linux that isn’t 64bit has been tough. I’m wondering too if it’s worth putting any effort into making this older tech work or if I should just move to a 64bit newer hardware? Thoughts?

LEAVE A REPLY

Please enter your comment!
Please enter your name here

This site uses Akismet to reduce spam. Learn how your comment data is processed.