First, you'll need to Download Docker for your platform.
Visit https://www.nicehash.com/register and create a new account.
NiceHash is a marketplace for buying and selling compute power. In our case, we're going to sell our cpu power. When you create an account, NiceHash will provide a mining and deposit address. We'll use this address in the next step.
With a NiceHash account and Docker installed, we're ready to start mining.
docker service create --name miner \ alexellis2/cpu-opt:2018-1-2 ./cpuminer \ -a cryptonight \ -o stratum+tcp://cryptonight.usa.nicehash.com:3355 \ -u 3HSFKUagtL5Z6KFE7gAJ3i9YgWkmaKH6Zb.miner1
This command will create a docker service called miner that will start CPU mining. You'll need to substitute
3HSFKUagtL5Z6KFE7gAJ3i9YgWkmaKH6Zb with the address generated when you created your NiceHash account. And you can replace
miner1 with the name of the host, if you want to track it.
If you're like me and you just want to mess around with this on your primary laptop, you'll probably not want to run the miner 100% of the time. I've create a few helper functions to start and stop mining.
First, create a file called start-mining and place it in /usr/local/bin or some other directory in your PATH:
#!/bin/bash docker service ps miner >/dev/null 2>&1 if [[ $? -eq 1 ]]; then docker service create \ --name miner \ alexellis2/cpu-opt:2018-1-2 \ ./cpuminer \ -a cryptonight \ -o stratum+tcp://cryptonight.usa.nicehash.com:3355 \ -u 3HSFKUagtL5Z6KFE7gAJ3i9YgWkmaKH6Zb.miner1 else docker service scale miner=1 fi docker service logs -f miner
And create an accompanying file called stop-mining.
#!/bin/bash docker service scale miner=0
Now we'll make these files executable:
chmod +x /usr/local/bin/start-mining chmod +x /usr/local/bin/stop-mining
The start-mining script creates the miner service if it does not yet exist and ensures the service has one worker if it exists. It's counterpart, stop-mining, simply scales the worker to zero.
If you need to remove the service completely, you can run:
docker service rm miner
First of all, CPU mining has a very low hash rate (like 15 H/s, compared to ASIC miners getting 15 TH/s). You will make some money, but you probably won’t be able to quit your job.
Second, electricity costs money and mining uses electricity.
If you're curious about what kinds of profits are possible, use this profitability calculator.