Monero CPU Mining with Docker Swarm Mode

Patrick

Administrator
Staff member
Dec 21, 2010
11,937
4,892
113
We recently released an image and guide for CPU Monero Mining with Docker. That works well for one system. What happens when you have a number of servers and want to put them to use during what would otherwise be downtime? Today we have a simple guide for getting this working.

If you are new to Docker swarm post-Docker 1.12, you can get up and running within 2-3 minutes.
Here is our Getting Docker Swarm Running in Minutes guide

Once this is setup, the actual process is exceedingly simple. Here we are taking a swarm that encompasses 4-nodes in a 2U chassis and we are making each node mine Monero.

Code:
docker service create --mode global --name m_test_01 -e username=example@example.com servethehome/monero_cpu_minergate
Key aspects to this:
  • We have 4 nodes. By default, Docker will try to run one replica on each node. Therefore, we could use --replicas 4. Instead, we are using --mode global to replicate on every node in our swarm. This is important since if we power off a node, Docker will try to re-balance and place a second mining container on a node.
  • We did give this service a name. You will want to kill this service when it is time to utilize the machines for normal production workloads. In this case we are using --name m_test_01 but you can use whatever you want there
  • We are using our minergate CPU mining image. You will need to replace "example@example.com" with your minergate username.
There are a few constraints with this approach. The biggest is that this is the "quick and dirty" way to target nodes. We are not using any filtering to target specific nodes.

We will soon have a cleaner way to manage mining along with your existing Docker services. In the meantime, using this method you can boot to an image that is part of the docker swarm and then automatically start mining Monero on the nodes. Once a node re-joins the swarm, it will automatically start running the mining image. You can also use commands such as:
Code:
$ docker service ls
ID            NAME       MODE    REPLICAS  IMAGE
uo4h4vpa5oid  m_test_04  global  4/4       servethehome/monero_cpu_minergate:latest
And see how many miners are running.
 
Last edited:

Marcos Laue

New Member
Jun 5, 2017
9
1
3
33
We recently released an image and guide for CPU Monero Mining with Docker. That works well for one system. What happens when you have a number of servers and want to put them to use during what would otherwise be downtime? Today we have a simple guide for getting this working.

If you are new to Docker swarm post-Docker 1.12, you can get up and running within 2-3 minutes.
Here is our Getting Docker Swarm Running in Minutes guide

Once this is setup, the actual process is exceedingly simple. Here we are taking a swarm that encompasses 4-nodes in a 2U chassis and we are making each node mine Monero.

Code:
docker service create --mode global --name m_test_01 -e username=example@example.com servethehome/monero_cpu_minergate
Key aspects to this:
  • We have 4 nodes. By default, Docker will try to run one replica on each node. Therefore, we could use --replicas 4. Instead, we are using --mode global to replicate on every node in our swarm. This is important since if we power off a node, Docker will try to re-balance and place a second mining container on a node.
  • We did give this service a name. You will want to kill this service when it is time to utilize the machines for normal production workloads. In this case we are using --name m_test_01 but you can use whatever you want there
  • We are using our minergate CPU mining image. You will need to replace "example@example.com" with your minergate username.
There are a few constraints with this approach. The biggest is that this is the "quick and dirty" way to target nodes. We are not using any filtering to target specific nodes.

We will soon have a cleaner way to manage mining along with your existing Docker services. In the meantime, using this method you can boot to an image that is part of the docker swarm and then automatically start mining Monero on the nodes. Once a node re-joins the swarm, it will automatically start running the mining image. You can also use commands such as:
Code:
$ docker service ls
ID            NAME       MODE    REPLICAS  IMAGE
uo4h4vpa5oid  m_test_04  global  4/4       servethehome/monero_cpu_minergate:latest
And see how many miners are running.
Using that Docker swarm image, there's advantage on h/s(performance of mining) comparing to just docker (Monero CPU Mining in Docker) based on a vps with 2 or 4 cores?
 

Patrick

Administrator
Staff member
Dec 21, 2010
11,937
4,892
113
Using that Docker swarm image, there's advantage on h/s(performance of mining) comparing to just docker (Monero CPU Mining in Docker) based on a vps with 2 or 4 cores?
Same images now. Just management via Swarm. At 1-2 nodes, no need for swarm. By the time you are at 20+ having some sort of orchestration is very helpful.
 

im10er

New Member
Feb 11, 2018
8
0
1
40
Sorry am I misunderstanding?

docker service create --mode global --name monero -e username=<wallet> -e pool="fcn-xmr.pool.minergate.com" -e startport=45590 -e workerid=`hostname` servethehome/universal_cryptonight

/usr/local/bin/xmrig.sh: line 96: 361 Illegal instruction (core dumped) ./xmrig -a cryptonight --av=1 --nicehash -o stratum+tcp://$pool:$startport -u $username.$workerid -p $pass -t $numthreads
 
Last edited:

Patrick

Administrator
Staff member
Dec 21, 2010
11,937
4,892
113
Sorry am I misunderstanding?

docker service create --mode global --name monero -e username=<wallet> -e pool="fcn-xmr.pool.minergate.com" -e startport=45590 -e workerid=`hostname` servethehome/universal_cryptonight

/usr/local/bin/xmrig.sh: line 96: 361 Illegal instruction (core dumped) ./xmrig -a cryptonight --av=1 --nicehash -o stratum+tcp://$pool:$startport -u $username.$workerid -p $pass -t $numthreads
I wonder if it is mixing the quotes that you are using in the launch line.
 

im10er

New Member
Feb 11, 2018
8
0
1
40
I think it had to do with the AES-NI issue again. Earlier when I was trying to run cpuminer I was getting an error with my manager node because it didn't have AES-NI

[ANN]: cpuminer-opt v3.8.1, open source optimized multi-algo CPU miner

I started a new manager and removed the other one and everything started working properly. Although I didn't test it with `hostname`... which can you explain to a noob, does that work in order for me to pass in my hostname as the worker?