General

Install & Use Docker

How to install and use Docker

Intro

We at EmberStake are heavily using Docker to run our services.
Here we want to give a brief overview of what Docker is and the benefits of using it over just downloading binaries.

What is Docker

Docker is an open-source platform that automates the deployment, scaling, and management of applications in lightweight, portable containers. Containers are isolated environments that package an application and its dependencies, ensuring consistent behavior across different environments. Docker simplifies software delivery by providing a standard way to run code and enables developers to build, ship, and run applications efficiently.

What is Docker Compose

Docker Compose is a tool for defining and running multi-container Docker applications. With Compose, you can use a YAML file to configure your application's services, networks, and volumes, making it easier to manage and orchestrate complex applications. By using a single command, you can create and start all the services defined in the configuration, simplifying the process of setting up and managing your application stack.

Benefits of using Docker containers for running nodes and other services

  • No need to use screen to keep your process alive: Docker ensures that your processes continue to run in the background without requiring additional tools like screen or tmux.
  • No need to make and manage systemd services: Docker handles the lifecycle of your applications, eliminating the need to create and manage systemd services.
  • No firewall manipulation for opening ports: Simply expose ports on the container, and your container is accessible from the outside world without manual firewall configurations.
  • Logs are more easily accessible and managed by Docker: Docker centralizes log management, making it easier to access, monitor, and analyze logs.
  • Portability: Easily migrate to a new server and be confident that everything will work as before, thanks to the consistency provided by Docker containers.
  • Deterministic runtime: Avoid conflicts and compatibility issues by packaging all dependencies within the container. You don't need to install multiple versions of Rust, Go, or other packages on the host OS; Docker handles it all.
  • Isolation: Containers provide a clean environment. Removing a container along with its volumes clears everything, ensuring no residual data or configurations.
  • Easier upgrades: Update applications seamlessly by pulling newer Docker images and recreating containers, simplifying the upgrade process.
  • Isolated private network: Run all services and connect them through an isolated private network, enhancing security and communication efficiency within your application stack.

By leveraging Docker, EmberStake ensures a robust, efficient, and streamlined deployment process for our services, allowing us to focus more on innovation and less on infrastructure management.

How to install Docker & Docker Compose

We can use the official get-docker script:

curl -fsSL https://get.docker.com -o get-docker.sh
sh get-docker.sh

If you are logged into a user other than root (which YOU ALWAYS SHOULD), add current user to the docker group:

sudo usermod -aG docker $USER
newgrp docker

Verify that you can run docker commands without sudo.

docker run hello-world

You should see Hello from Docker!

Configure Docker to start on boot with systemd

sudo systemctl enable docker.service
sudo systemctl enable containerd.service

Now you can run docker containers, using docker daemon or docker compose