Guide for Installing and Configuring Docker on Linux. Installing and configuring Docker on Linux is a simple process if you follow the correct steps.
Once configured, Docker provides a secure, fast and efficient environment for development and running applications.
It is an essential tool for system administrators, developers and DevOps teams.
Guide for installation and configuration
Docker is an open-source platform that allows running applications in isolated containers, easy to manage and portable.
This guide will teach you how to install and configure Docker on a Linux system, step by step, to benefit from the advantages of modern containerization.
Prerequisites
Make sure you have:
- An updated Linux system (Ubuntu, Debian, CentOS, etc.);
- Root access or sudo privileges;
- Internet connection.
Guide for Installing and Configuring Docker
1. System update
Start by updating the packages:
sudo apt update && sudo apt upgrade -y
2. Installing Docker on Ubuntu/Debian
2.1 Installing required packages
sudo apt install ca-certificates curl gnupg lsb-release -y
2.2 Adding Docker’s GPG key
sudo mkdir -p /etc/apt/keyrings curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /etc/apt/keyrings/docker.gpg
2.3 Adding the official Docker repository
echo "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
2.4 Installing Docker Engine
sudo apt update sudo apt install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin -y
3. Verifying the installation
To verify if Docker is installed correctly:
sudo docker --version
Running a test container:
sudo docker run hello-world
4. Adding user to docker group
To use Docker without sudo:
sudo usermod -aG docker $USER newgrp docker
5. Enabling and starting Docker service
sudo systemctl enable docker sudo systemctl start docker
6. Configuring Docker
The configuration file is located at:
/etc/docker/daemon.json
Configuration example with logging and custom network:
{
"log-driver": "json-file",
"log-opts": {
"max-size": "10m",
"max-file": "3"
},
"storage-driver": "overlay2"
}
Apply the changes:
sudo systemctl restart docker
7. Installing Docker Compose (if not included)
For some older distributions:
sudo curl -L "https://github.com/docker/compose/releases/latest/download/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose sudo chmod +x /usr/local/bin/docker-compose docker-compose --version
8. Quick test with an nginx container
Run a simple web server:
docker run -d -p 8080:80 --name nginx-server nginx
Then access http://localhost:8080 in your browser.
9. Useful Docker commands
docker ps– displays active containersdocker stop ID– stops a containerdocker rm ID– deletes a containerdocker images– lists downloaded imagesdocker exec -it ID bash– accesses an active container
10. Uninstalling Docker (optional)
To completely remove Docker from the system:
sudo apt purge docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin sudo rm -rf /var/lib/docker /etc/docker sudo rm /etc/apt/sources.list.d/docker.list

Comments (0)