Docker Tutorial
Docker is an open-source platform that enables developers to build, deploy, run, update, and manage applications in a standardized, executable unit called a container. Containers package an application's source code, along with all the operating system libraries and dependencies required to run that code, ensuring consistent performance across any environment.
We often use docker for our back-end applications, it helps us execute our code base in a predictable manner from local development environments all the way to production.
Note: The rest of the documentation assumes you have the same OS we use. Click here to follow the installation guide.
For more information on what Docker is and how it works, read more here.
Install Docker Engine on Debian
To install Docker Engine on Debian using the official Docker repository, follow these steps:
Step 1: Set up Docker's apt repository
# Add Docker's official GPG key:
sudo apt-get update
sudo apt-get install ca-certificates curl
sudo install -m 0755 -d /etc/apt/keyrings
sudo curl -fsSL https://download.docker.com/linux/debian/gpg -o /etc/apt/keyrings/docker.asc
sudo chmod a+r /etc/apt/keyrings/docker.asc
# Add the repository to Apt sources:
echo \
"deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.asc] https://download.docker.com/linux/debian \
$(. /etc/os-release && echo "$VERSION_CODENAME") stable" | \
sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
sudo apt-get update
The Docker service starts automatically after installation. To verify that Docker is running, use:
sudo systemctl status docker
Some systems may have this behavior disabled and will require a manual start:
sudo systemctl start docker
Step 2: Install Docker packages
sudo apt-get install -y docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin
Step 3: Verify installation
sudo docker run hello-world
You should see a message indicating that your installation appears to be working correctly.
Basic Docker Commands
-
Check version:
docker --version -
List running containers:
docker ps -
List all containers (including stopped):
docker ps -a -
Stop a container:
docker stop <container_id> -
Remove a container:
docker rm <container_id> -
List images:
docker images -
Remove an image:
docker rmi <image_id>
For more in-depth learning on Docker's concepts, head to its official Get started documentation.