Step-by-Step Guide to Installing Docker and Docker Compose on Linux VMs
Simplify Your Containerization Journey with This User-Friendly Tutorial
Welcome to our concise guide to installing Docker and Docker Compose on Linux virtual machines. This step-by-step manual demystifies the installation procedure and enables you to confidently enter the containerization world, a crucial skill for both system administrators and developers.

This blog assumes that you have just launched a VM and are at least connected to it through your local terminal via SSH. However, there are other ways to connect to your VM; the point is that you should be able to run commands on your VM.
Table of contents
· Install Prerequisites · Install Docker · Install Docker Compose · Conclusion
Install Prerequisites
Docker installation is a prerequisite for building and deploying a Docker image, and for Docker to be installed, there are some additional prerequisites. 😃
# Updates the package index on your system
sudo apt update
# Installs the necessary packages for adding a new repository and managing secure connections:
sudo apt install apt-transport-https ca-certificates curl gnupg lsb-release -y
# Downloads the Docker GPG key and saves it to a keyring file:
curl -fsSL https://download.docker.com/linux/debian/gpg | sudo gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg
# Adds the Docker repository to your system's package sources:
echo "deb [arch=amd64 signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://download.docker.com/linux/debian $(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
# Updates the package index on your system
sudo apt updateInstall Docker
Now that we are ready to install Docker, let’s install the following Docker components:
- docker-ce: Docker Community Edition, the core Docker engine that manages containers, images, and other Docker objects.
- docker-ce-cli: Docker Community Edition Command Line Interface, which provides the docker command for interacting with the Docker engine.
- containerd.io: containerd is a container runtime used by Docker to manage container execution and supervision.
sudo apt install docker-ce docker-ce-cli containerd.io -y
# Enables the Docker service to start automatically at system boot.
# It creates a symlink in the appropriate systemd directory, ensuring that the Docker service is started when the system boots up.
sudo systemctl enable docker
# Starts the Docker service immediately.
# After running this command, the Docker engine will be running, and you can use Docker commands to manage containers and images.
sudo systemctl start docker
# This command displays the installed Docker version. Verifies that the docker installation is comeple.
docker --versionInstall Docker Compose
Docker Compose makes it easier to orchestrate and manage multi-container applications, while Docker is in charge of creating and managing individual containers. Together, they effectively manage application dependencies, deploy services, and manage their configurations to improve the containerization experience. Use the commands listed below to install Docker Compose.
# This command downloads the Docker Compose binary on the system.
sudo curl -L "https://github.com/docker/compose/releases/download/1.29.2/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
# This command makes the downloaded Docker Compose binary executable.
sudo chmod +x /usr/local/bin/docker-compose
# This command displays the installed Docker Compose version.
docker-compose --versionConclusion
With the help of our detailed instructions, you can install Docker and Docker Compose on Linux virtual machines. Utilize your newly acquired skills to streamline deployments as you continue to learn about containerization so that you can stay on the cutting edge of this fast-paced industry. Happy containerizing!





