Last week, we created an AWS account, deployed an EC2 Linux instance and learned how to SSH into that server. With the help of Docker, we’ll deploy a private NEO network within the linux AMI we’ve just created!
So what is Docker? Docker is containerization technology — it helps us run an “image” or package, where we don’t have to worry about the NEO nodes, network, dependencies and any pre-configurations. It is all written out for us as a docker image, all we need to do is download and run it!
Lets, though, take a moment to understand our particular Docker image. It contains 4 NEO consensus nodes, the minimum required to bring up a working NEO network, communicating internally via ports 30333-30336 TCP. We will then expose the testNet communication ports (20331–20334) to the outside world by manipulating our AWS security group.
After entering your Amazon Linux instance via secure shell, we will install Docker …
Step 1: Install Docker
sudo yum update -y
sudo yum install -y docker
sudo service docker start
sudo usermod -a -G docker ec2-user
Step 2: Check and deploy our Docker NEO network image
docker info #just a check
docker pull cityofzion/neo-privatenet
docker run --rm -d --name neo-privatenet --expose=20331-20334 --expose=30333-30336 -p 20333-20336:20333-20336/tcp -p 30333-30336:30333-30336/tcp cityofzion/neo-privatenet
Check that your image is running!
Step 3: Adding port 30331–30334 to your security group
Log onto the AWS console, Services > EC2. Under NETWORK & SECURITY, click Security Groups. Click Edit on the security group assigned to your instance. Create the following inbound rules:
*These rules apply immediately!
Step 4: Connect from your neo-prompt!
Open command prompt on local:
cd <location of neo-python>
Remember how we made note of the public IP in the last article? Let’s use that here:
np-prompt -p <server IP>
Great! we are done!
Bonus command: Restarting the NEO block-chain.
From our experience, due to server memory constraints, your image will need to be whipped and restarted weekly. The command to do so is as follows:
docker stop neo-privatenet
Then use the following on your own np-prompt (Ubuntu):
rm -rf /root/.neopython/Chains/
As usual, I’ll give my project a shout out: Nodis.io is a marketing platform for local business, generating engagement through small activities and rewarding users with cryptocurrency they can later spend on these stores. Check us out and give us your feedback on Instagram and Facebook!
Next week’s guide: Deploying a NEP-5 smart contract (part 1)