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 -yInstall required packages:
sudo apt install apt-transport-https ca-certificates curl software-properties-common -yAdd Docker’s official GPG key:
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpgAdd 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/nullInstall Docker Engine:
sudo apt update && sudo apt install docker-ce docker-ce-cli containerd.io -yVerify 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:latestList downloaded images:
docker imagesRemove an image:
docker rmi ubuntu:latest
Running Containers
Run a container in interactive mode:
docker run -it ubuntu /bin/bashRun a container in detached mode (background):
docker run -d --name my_container nginxList running containers:
docker psList all containers (including stopped ones):
docker ps -aStop a container:
docker stop my_containerStart a stopped container:
docker start my_containerRemove 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 nginxMount a host directory as a volume:
docker run -v /host/path:/container/path ubuntu
Docker Logs & Exec
View container logs:
docker logs my_containerExecute 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! 🐳



