Docker is a tool that allows you to quickly create, test, and deploy applications. The idea behind Docker is to create “containers” that are lightweight and portable so that applications can run on any machine with Docker installed, regardless of the operating system.
For example, each node of the blockchain network or service / application developed will be compiled into a docker image that contains all of its dependencies and is deployed to one of several infrastructure providers with docker available.
In addition to Docker we use a container “orchestrator” tool called Kubernetes (K8s).
Kubernetes helps you manage the containers in which your applications are hosted in an easy, fast, and scalable way. In addition, it also has load monitoring and balancing. About virtual servers. More information.
Docker Engine is an open source containerization technology for building and containerizing your applications. Docker Engine acts as a client-server application with:
- A server with a long-running daemon process dockerd.
- APIs which specify interfaces that programs can use to talk to and instruct the Docker daemon.
- A command line interface (CLI) client docker.
The CLI uses Docker APIs to control or interact with the Docker daemon through scripting or direct CLI commands. Many other Docker applications use the underlying API and CLI. The daemon creates and manage Docker objects, such as images, containers, networks, and volumes.
For more details, see Docker Architecture.
To have an initial docker configuration, we need to set up three main thing:
- Dockerfile: Define the steps needed to create the image and run it. Each instruction in a Dockerfile creates a layer in the image.
- Image: An image is a read-only template with instructions for creating a Docker container.
- Container: A container is a runnable instance of an image. You can create, start, stop, move, or delete a container using the Docker API or CLI.
Compose is a tool for defining and running multi-container Docker applications. With Compose, you use a YAML file to configure your application’s services. Then, with a single command, you create and start all the services from your configuration.
Using Compose is basically a three-step process:
- Define your app’s environment with a Dockerfile so it can be reproduced anywhere.
- Define the services that make up your app in docker-compose.yml so they can be run together in an isolated environment.
- Run docker-compose up and Compose starts and runs your entire app.
A docker-compose.yml looks like this:
To start our first Docker project, we are going to create the needed configuration to make it start and says
Hello world, we are EOS Costa Rica 🦋. First of all, we need the main configuration, so follow next steps to get it.
docker build -t eoscostarica/helloworld:1.0 .
docker run -p 5000:8080 <image-id>