Best Fintech Resources & Lending Technology Trends | Skeps Blog

Deploying Blockchain Applications with Docker

Written by Swati Bucha | Dec 5, 2019 11:19:39 AM

Docker provides great support in quickly getting a blockchain node up and running without the need to individually configure each machine separately.

Blockchain and Docker are technical innovations with tremendous potential in developing and maintaining application software.

Blockchain refers to a type of database architecture in which data is stored in a distributed fashion on a decentralized system of nodes. Blockchain is a revolutionary technology because it helps to decrease financial data leak risk, curtails fraudulent transactions, and increases transparency in a scalable way.

Docker is an open-source software for deployment and development of applications within containers. These containers allow developers to emulate applications regardless of the technical environment.

Simply put — it is Build, Ship and Run any application, anywhere.

This post is an attempt to explore docker and its application for blockchain technology. We sincerely hope this piece provides a basic understanding of the usage and merits of these emerging technologies.

A real-time challenge and a possible solution

In an organization, development and operations teams function in separate environments. The code/software application which works fine in the developer’s machine might not behave similarly in the operations machine due to varied configuration, version & build difference of the supporting software, etc.

In such a scenario, the docker container provides a possible solution by packaging everything required to make the software run.

Docker enables you to build a container image which when run becomes a Container. The users can utilize this image across different release and development phases which would help to standardize the environment.

Container image can be distributed among team members or an organization multiple times to ensure that the environment is constant and behaves the same to better anticipate, identify and resolve the issues.

The image can also be pushed to docker Hub (https://hub.docker.com/) and pulled back as per the requirement (Anytime-Anywhere)

Technicalities – How does docker work?

Docker has three important components

  1. Docker file
  2. Docker Image
  3. Docker Container

Docker file contains the specifications (code, runtime, system tools, system libraries, and settings) required for the container.

A docker container image is a lightweight, standalone, executable package of software that includes code and necessary information/specifications needed to run an application.

A container is a standard unit of software that packages the code and all its dependencies, so the application runs quickly and reliably from one computing environment to another. Container images become containers at runtime.

Let’s get started! Installing docker

Docker can be installed on a Linux Ubuntu machine by using the following commands. The following commands have been arranged such that it can be copied in a shell script and executed directly. (Reference*)

sudo apt-get install \
apt-transport-https \
ca-certificates \curl \
gnupg-agent \
software-properties-common
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add
sudo apt-key fingerprint 0EBFCD88
sudo add-apt-repository \
“deb [arch=amd64] https://download.docker.com/linux/ubuntu \
$(lsb_release -cs) \
stable”
sudo apt-get update
sudo apt-get install docker-ce docker-ce-cli containerd.io

Congratulations! You have successfully installed a docker. You can test the installation by typing $ sudo docker -v which would give an output of the version of the docker.

Creating a docker file and building it

  • Create a dockerfile
    Pulling a tomcat image to exemplify.
FROM tomcat:8.5.45-jdk8-openjdk
EXPOSE 8080
CMD [“catalina.sh”, “run”]
  • Create an Image
$docker build -t <name>

Check the list of images created

$ docker image ls
  • Convert Image to Container
$ docker run -p <port Number>:<port number> <Container Name><Image Name>
  • Check the list of containers running
$ docker container ps

Dealing with backup and Data Recovery

All looks fine as of now! You might be wondering what happens to the data in case of a container crash. Fortunately, docker provides a mount option where data can be saved in either volumes or bind mounts. Bind mounts are dependent on the directory structure of the host machine whereas volumes are completely managed by the docker.

  • Create a Volume
$ docker volume create volumename

The volume name is provided while running the image to a container.

$ docker run -d name=containername mount source=volumename,destination=path imagename
  • Check Logs

You can also check logs of your container by

$ docker logs –f containername
  • Pushing an image to Docker Hub

Login to Docker Hub

$ docker login

Execute the command to push

$ docker push repository-name/imagename

Frequently used docker container commands at a glance

$ docker start containername
$ docker stop containername
$ docker restart containername
$ docker inspect containername
$ docker exec -it containername /bin/bash
$ docker commit containername newimagename
$ docker save containername > containername.tar
$ docker load — input containername.tar
$ docker logs -f containername

Docker repository push commands

$ docker pull repositoryname/imagename
$ docker push repositoryname/imagename

Deploying Blockchain using docker Hub

Given the nascent nature of the blockchain ecosystem, scaling up a blockchain network in an enterprise environment can be challenging. This is where docker provides great support in quickly getting a blockchain node up and running without the need to individually configure each machine separately.

Docker Hub provides images for all major enterprise blockchain networks:

These images are a great starting point and can take away a lot of effort required for setting up the blockchain network. At the same time, building your blockchain network using docker ensures that the system can be easily scaled up or down without the usual headaches of managing a blockchain.

In a nutshell, docker is a free open source that facilitates faster software delivery and ensures consistency among different environments. Thus, saving time, effort and money. What can be more wonderful than this!

Skeps is working on some ground-breaking technology to make a dent in the financial services industry. To know more about the product we are developing, please visit our homepage.

/ * Reference — https://docs.docker.com/install/ */