Docker Fundamentals: Installation, Configuration, and Basic Usage


Introduction
Docker is a powerful platform for developing, shipping, and running applications in lightweight, portable containers. Unlike traditional virtual machines, Docker containers share the host OS kernel, making them faster and more efficient.
In this blog, we'll cover:
Docker Installation
Basic Configuration
Fundamental Docker Commands
1. Docker Installation
On Linux (Ubuntu/Debian)
Update your system:
sudo apt update && sudo apt upgrade -y
Install required packages:
sudo apt install apt-transport-https ca-certificates curl software-properties-common -y
Add Docker’s official GPG key:
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg
Add Docker repository:
echo "deb [arch=amd64 signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
Install Docker Engine:
sudo apt update && sudo apt install docker-ce docker-ce-cli containerd.io -y
Verify installation:
sudo docker run hello-world
On Windows/macOS
Download Docker Desktop from the official website:
Follow the installation wizard.
After installation, open a terminal and verify:
docker --version
2. Docker Configuration
Managing Docker as a Non-Root User (Linux)
By default, Docker requires sudo
. To avoid this:
sudo usermod -aG docker $USER
newgrp docker
Now, you can run Docker commands without sudo
.
Starting & Enabling Docker Service (Linux)
sudo systemctl start docker
sudo systemctl enable docker
Configuring Docker to Start on Boot (Windows/macOS)
- Open Docker Desktop → Settings → General → Enable "Start Docker Desktop when you log in".
3. Basic Docker Usage
Working with Docker Images
Pull an image from Docker Hub:
docker pull ubuntu:latest
List downloaded images:
docker images
Remove an image:
docker rmi ubuntu:latest
Running Containers
Run a container in interactive mode:
docker run -it ubuntu /bin/bash
Run a container in detached mode (background):
docker run -d --name my_container nginx
List running containers:
docker ps
List all containers (including stopped ones):
docker ps -a
Stop a container:
docker stop my_container
Start a stopped container:
docker start my_container
Remove a container:
docker rm my_container
Managing Ports & Volumes
Expose a container port to the host:
docker run -d -p 8080:80 --name nginx_server nginx
Mount a host directory as a volume:
docker run -v /host/path:/container/path ubuntu
Docker Logs & Exec
View container logs:
docker logs my_container
Execute a command inside a running container:
docker exec -it my_container /bin/bash
Conclusion
Docker simplifies application deployment by encapsulating environments into containers. We covered:
✅ Installation on Linux, Windows, and macOS
✅ Basic configuration (non-root access, auto-start)
✅ Essential commands for managing images & containers
Next steps? Try building your own Docker images using Dockerfile
and explore Docker Compose for multi-container setups!
Happy Dockering! 🐳
Subscribe to my newsletter
Read articles from Sdeep directly inside your inbox. Subscribe to the newsletter, and don't miss out.
Written by

Sdeep
Sdeep
👋 Hello! I'm passionate about DevOps and I'm proficient in a variety of cutting-edge technologies and always motivated to expand my knowledge and skills. Let's connect and grow together!