Mining AION Coins in Docker

Hi AION fellows,

I would like to present you my github repo where I created a docker-compose setup for mining AION tokens on the testnet using Docker containers.
You can find the github repo at: https://github.com/sh39sxn/mining-aion-coins
You find the prebuild Docker Containers on Docker Hub:
Kernel: https://hub.docker.com/r/sh39sxn/aion-kernel/
Solo mining pool: https://hub.docker.com/r/sh39sxn/aion-solo-mining-pool/
CPU Aionminer: https://hub.docker.com/r/sh39sxn/aion-miner-gpu/
GPU SmartMiner: https://hub.docker.com/r/sh39sxn/aion-smartminer/
GPU Aionminer: https://hub.docker.com/r/sh39sxn/aion-miner-cpu/

If you have installed Docker and docker-compose on your host machine you only have to run “docker-compose up” and it will create a whole mining environment (4 Containers: solo mining pool, kernel, redis, cpu miner)
You can also just use/start one of the containers, e.g. the Kernel Container in order to use it with your GPU miner. The corresponding ports are opened to localhost.
At the moment I only configured a Container for mining tokens using CPU but I can extend it mining tokens with GPUs.

It was a lot of work and I hope it will help some of you mining tokens.
In my opinion using docker has many advantages like easier deployments etc. Just throw the old container away and start a new one if there is a new release or something is broken.
I would like to get your feedback :slight_smile:

Best regards,
Chris

6 Likes

Wow this is amazing @chris1! I’ll try it out sometime this week! Please let us know when the GPU miner is out as well :slight_smile:

A few questions:

  • How can we update the kernel version when new ones are released?
  • How can we call other kernel commands?

Thanks :slight_smile:

Good job.
I suggest few improvements:

  • Not to encourage user to edit some files but allow usage of environment variables for parameters settings and to fail gracefully (with explanatory error message) if they are not set
  • Allow select number of threads. Sometimes it is not desirable to use all 100% CPU power for mining.
2 Likes

Very nice! Good job on those docker files. I agree with @tarm that it would be nicer if there was some build script or something with environment variables to change the address and kernel version, etc.

Also, you call them AION tokens, but they are actually AION coins. Just a tiny detail :slight_smile:

1 Like

great job … thanks a bundle

@road_to_one_trillion
The easiest way to handle new Kernel releases would be that you provide a static link pointing to the newest release in github. Currenty the kernel is downloaded via a url like https://github.com/aionnetwork/aion/releases/tag/v0.1.19
I don’t know if it’s possible to create a public link like https://github.com/aionnetwork/aion/releases/tag/latest which is automatically always pointing to newest release/tar.bz2 file? It doesn’t have to be a link using github.com url.
Then you would only need to build the Docker Container again without modifying the Dockerfile.
I have experience with Gitlab CI/CD Pipeline. So I could set up a Build Pipeline, too. Or the prebuild containers are published on dockerhub. That could provide more presence of the AION project in the docker world.

For running commands you can start a Kernel Container in interactive mode, e.g.:
docker run -it --rm -p 8545:8545 --name kernel aion:kernel _your_command_
Is this info enough or did you have some specific commands in mind?
If you want to run a command against the currently running kernel Container. Try docker-compose ps to get a list of running Containers and then use the Container ID shown in the list and try something like docker exec -it CONTAINER_ID bash

@tarm @Jim
thank’s for this suggestion.
Regarding CPU threads: My plan was to use not a fix number (currently 2) of threads. I completely agree to create something dynamic for it. But it was important for me to publish the project asap to get the first feedback.
I will think about a build script. One of my goals is that somebody who has very low knowledge about Docker can still use this project. But I can use default settings which can be overriden if wanted :slight_smile:
And thank’s: I renamed the repo in the meanwhile using “coins” instead of “tokens” :wink:

2 Likes

@chris1 thanks that response answers my questions! This link should always point to the latest release: https://github.com/aionnetwork/aion/releases/latest as explained here (for those who are curious: https://help.github.com/articles/linking-to-releases/)

Hello @chris1 ! Thanks for the great job :slight_smile: I am on MacOS and it works out of the box (well it seems for the moment… I should re-comment that in a few minutes… and YES I confirm it works - edit - )

Although it is a little slow to build it from scratch where I am (ubuntu apt mirrors for instance).

A suggestion you may have already considered:

  • You could make a docker hub repo for each of your docker files (core, pool, miner-cpu, miner-gpu), with a pre-built image, each exposing the parameters to be played with in environment variables.
  • You would use the docker image versions to match the versions of the aion core/pool/miner releases.
  • Then, on your github you host simply docker-compose.yml files for each version of the full rig, in which you use matching versions of your pre-built images.

=> then anybody could just use the latest version of your latest/docker-compose.yml to start the latest version of the mining rig

=> it would also allow to re-use previous versions with something as simple as “docker pull aion-chris1:0.1.19” or “docker pull aion-chris:latest”

If you are interested to have contributors on your github, I’d be glad to give a hand. Docker could make things quite easy :slight_smile:

Although, how would you do to access GPUs from Docker ?

Cheers !

2 Likes

@road_to_one_trillion
thank’s for the links. The problem I wanted to point to is that using the link https://github.com/aionnetwork/aion/releases/latest doesn’t point to the actual tar.bz2 file. But with the help of stackoverflow I could use a curl command and the github api to get the download link.
As @xvin3t suggested I dediced to use docker tags for the different kernel/miner/pool versions. The Docker tags are made exactly for such use cases. I already started to create Docker Hub Repos (not yet public) in order to achieve this and to increase build speed. Great to hear that it worked out of the box @xvin3t
And thank’s for our offer to give me a hand on the github repo. For now I have enough capacity but I will come back to you if the demand increases. Thank’s!
Regarding GPU and Docker: you can use nvidia-docker to access GPUs within Docker Containers, see https://github.com/NVIDIA/nvidia-docker
It’s not so easy to set it up but I already did it for mining Monero. My experience was that you have to take care which Cuda Toolkit Version you are using. Version 8 is less problematic than version 9.

1 Like

Just a short update:
I finished adapting the Dockerfiles for using environment variables.
You can find the Docker images for CPU Miner and AION Kernel at:
https://hub.docker.com/r/sh39sxn/aion-miner-cpu/
https://hub.docker.com/r/sh39sxn/aion-kernel/

I think that’s what some of you suggested and I like this way. No adjusting of Dockerfiles anymore.
The solo mining pool is in planing :slight_smile:

1 Like

Great Job @chris1 ! Thank you for sharing your work :slight_smile:
Are you also on to the GPU version ?

1 Like

Thank’s @xvin3t
I finished the GPU and solo mining pool Container.
Check it out at:

https://hub.docker.com/r/sh39sxn/aion-miner-gpu/

https://hub.docker.com/r/sh39sxn/aion-solo-mining-pool/

I also updated my GitHup Repo explaining how to use docker-compose with the Docker Hub images.

PS: I’m happy about staring my github and docker hub repos :wink:

2 Likes

Hello Chris, once again great job.

Did you already work on the kernel 2.4 ?
Would it be ok for you to share your docker files or share the repo so new users may implement the latest version in case you are not available ?

Thank you !

@gpbrice thank’s for your appreciation :slight_smile:
You probably didn’t read the whole thread. I already published my Dockerfiles in my GitHub Repo:

I didn’t implemented v2.3 and v2.4 of the kernel as Docker Containers. The updates came so fast I didn’t recognized it :wink:
Feel free to add pull requests to github if you have improvements. @xvin3t already offered me some help
I want to achieve that you can use the newest kernel/miner versions when the public mainnet is launched next week.

Actually I would also like to use a CI Pipeline to test the Docker containers sufficiently, e.g. mining coins, checking the balance etc.

1 Like

Hello @chris1!

So far im using the pool and kernel, making it really simple to get started. For the miner gpu, im now testing it. @gpbrice is my friend and we are doing this together. Ill add request on the Github if a version is missing.
For the testing pipeline i have no experience in it but I would be glad to learn and help.

Cheers !

I just released Kernel Version 0.2.3 and 0.2.4 on DockerHub :slight_smile:
Please try it and tell me if something is not working.

@xvin3t
nice that you guys together start mining, makes probably more fun :smiley:
Then let’s see when we set up a CI Pipeline. I will let you know.

1 Like

That’s great, thanks Chris! :raised_hands:t3:

[email protected]:~/mining-aion-coins$ sudo apt-get install docker-composeReading package lists… Done
Building dependency tree
Reading state information… Done
docker-compose is already the newest version (1.8.0-2).
0 upgraded, 0 newly installed, 0 to remove and 119 not upgraded.

[email protected]:~/mining-aion-coins$ docker-compose up
ERROR: Version in “./docker-compose.yml” is unsupported. You might be seeing this error because you’re using the wrong Compose file version. Either specify a version of “2” (or “2.0”) and place your service definitions under the services key, or omit the version key and place your service definitions at the root of the file to use version 1.
For more on the Compose file format versions, see https://docs.docker.com/compose/compose-file/

this is where im stranded now :confounded:

oh im using ubuntu 17.10.1, is that the issue?

@kwarktaart
Obviously apt didn’t install the newest version of docker-compose.
Please try the official way to instal docker-compose described at https://docs.docker.com/compose/install/#install-compose
Basically it’s just two commands on linux.
Ubuntu 17.10.1 shouldn’t be a problem.

If you want to use the GPU miner in Docker you have to change the default runtime of Docker to nvidia. When I have time I will update my Repo Readme to explain how. But if you google for it you can find some explanations about it.

[email protected]:~$ sudo curl -L https://github.com/docker/compose/releases/download/1.21.0/docker-compose-uname -s-uname -m -o /usr/local/bin/docker-compose
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 617 0 617 0 0 617 0 --:–:-- --:–:-- --:–:-- 1177
100 10.3M 100 10.3M 0 0 3535k 0 0:00:03 0:00:03 --:–:-- 3409k
[email protected]:~$ sudo chmod +x /usr/local/bin/[email protected]:~$ docker-compose --versiondocker-compose version 1.8.0, build unknown

Kinda tried that already