Post

How to install Docker & Docker Compose

How to install Docker & Docker Compose

What is Docker?

Docker is an open-source platform that automates the deployment of applications within lightweight containers. These containers encapsulate everything an application needs to run, including code, runtime, system tools, libraries, and settings, ensuring consistency across different environments. Docker utilizes containerization technology to isolate applications from their underlying infrastructure, making them portable and scalable.

Key Benefits of Docker:

  1. Portability: Docker containers can run on any platform that supports Docker, eliminating compatibility issues and streamlining the deployment process.
  2. Isolation: Containers provide a level of isolation that ensures applications run independently of the host system, enhancing security and reliability.
  3. Resource Efficiency: Docker containers consume fewer resources compared to traditional virtual machines, leading to improved resource utilization and cost savings.
  4. Consistency: Docker ensures consistency between development, testing, and production environments, reducing the likelihood of “it works on my machine” issues.
  5. Scalability: Docker enables seamless scaling of applications by spinning up additional containers to handle increased workload demands.

What is Docker Compose?

Docker Compose is a tool that simplifies the management of multi-container Docker applications. It uses a YAML file to define services, networks, and volumes required for an application, allowing developers to orchestrate the deployment of complex applications with ease. Docker Compose facilitates the configuration of interconnected containers, automating tasks such as networking, volume mounting, and environment variable management.

Key Features of Docker Compose:

  1. Service Definition: Docker Compose allows developers to define multiple services within a single YAML file, specifying container images, ports, volumes, and environment variables.
  2. Inter-Container Communication: Docker Compose simplifies inter-container communication by automatically creating a network that enables seamless interaction between services.
  3. Environment Management: Docker Compose supports the management of environment variables, allowing developers to configure application settings dynamically.
  4. Volume Mounting: Docker Compose facilitates volume mounting, enabling data persistence across container restarts and ensuring seamless application state management.
  5. Scalability: Docker Compose supports scaling of services, allowing developers to increase or decrease the number of containers based on workload requirements.

Install Docker on Linux (Debian)

1
2
3
4
5
6
7
8
9
10
11
sudo apt update

sudo apt 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 add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable"

sudo apt update

sudo apt-get install docker-ce docker-ce-cli containerd.io

Verify Docker is installed correctly

1
sudo docker run hello-world

Install Docker-Compose on Linux (Debian)

Download the latest version (in this case it is 1.25.5, this may change whenever you read this tutorial!)

1
2
3
sudo curl -L "https://github.com/docker/compose/releases/download/1.25.5/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose

sudo chmod +x /usr/local/bin/docker-compose

Verify Docker-Compose is installed correctly

1
sudo docker-compose --version

Add your USER to the docker group to use Docker Command

1
sudo usermod -aG sudo,adm,docker $USER

This post is licensed under CC BY 4.0 by the author.