I've been working as a software engineer for years, tackling everything from legacy monoliths to modern microservices. Frankly, being a programmer isn't enough anymore; we need operational skills like Docker.
Many jobs today don't just require React, Go, or Python; they also demand additional skills like Docker. That's why you must learn Docker, whether you're an IT student or a junior developer.
In a real company, nobody installs databases, Nginx, Node.js, Redis, or PostgreSQL directly on their servers anymore. We spin them up in throwaway containers. Learning this now puts you years ahead of your peers.
Note: This approach also helps secure your environment, making it much harder for attackers to inject unwanted files into your server.
Docker: The Standard for App Packaging
Packaging applications along with all their necessities (code, libraries, dependencies, etc.) into a single unit called a container.
Originally created in 2010 as an internal project named dotCloud, Docker was officially released as an open-source project in March 2013.
So what is docker ?
Docker is a platform that allows you to package your application and its dependencies into a container, which can then be run on any machine that has Docker installed.
Without Docker, you often face environment issues like when we move it to other computer, friends, or server. you have to install nodejs, mysql, redis, postgresql, nginx, etc. and sometimes it also doesn't work because the version of the application is different.
But with docker, you just install Docker, run docker compose up, and your entire stack is live.

The Mental Model (Analogies)
If you're confuse let me bring you to understand Docker concepts through food:
- Docker Image = The Ingredients / Recipe (e.g., Raw Instant Noodle pack). It is the blueprint.
- Docker Container = The Cooked Meal (e.g., The bowl of noodles ready to eat). It is the running instance of the image.
- Docker Compose = The Set Menu (e.g., Fried Noodles + Lemon Tea + Side Dish). It defines and runs multiple containers together.
- Docker Hub = The Supermarket. The global warehouse where you download basic ingredients (Images).
- Docker Desktop = The Menu Card / GUI. A visual interface to manage your orders.
Initial Setup
First, let's check if Docker is installed correctly by running the following command:
docker --version
docker info
If Not, you can download it from Docker's official website.
Docker Syntax Cheat Sheet
Below This is the cheat sheet for docker commands, you can copy and paste it to your terminal. If you don't understand what the command does, just google it.
Working with Images
docker pull [image_name] # Download an image from Hub
docker images # List all downloaded images
docker rmi [image_id] # Delete an image
Working with Containers
docker run [image_name] # Create and start a container
docker ps # List running containers
docker ps -a # List ALL containers (including stopped ones)
docker stop [container_id] # Stop a running container
docker start [container_id] # Start a stopped container
docker rm [container_id] # Delete a container
Note: You can use the container name instead of the ID for commands like stop and rm.
The "Run" Command Explained
docker run is like ordering and eating immediately.
docker run node
If the node image isn't on your machine, Docker will automatically download it (pull) and then start it.
Useful Flags:
-d: Detached mode. Runs the container in the background (so it doesn't lock your terminal).-it: Interactive terminal. Allows you to interact with the container (like a shell).--name: Assign a custom name to your container.
Example:
docker run -d -it --name my_node_app node
Advanced Interactions
Jumping Inside a Container
To run commands inside a running container (like SSH-ing into it):
docker exec -it [container_name] bash
# If bash isn't installed, try sh:
docker exec -it [container_name] sh
Building Your Own Image
If you have a Dockerfile:
# -t gives it a tag (name:version)
# . means "look in the current directory"
docker build -t peter-portfolio:1.0.0 .
Networking & Environment Variables
Port Mapping (-p): Expose a port from the container to your host machine.
# syntax: -p [host_port]:[container_port]
docker run -d -p 3000:3000 peter-portfolio:1.0.0
Environment Variables (-e): Inject secret keys or configuration without changing the code.
docker run --name postgres-db \
-e POSTGRES_USER=root \
-e POSTGRES_PASSWORD=secret \
-d postgres:12-alpine
This command:
- Names the container
postgres-db. - Sets the user to
root. - Sets the password to
secret. - Runs it in the background (
-d). - Uses the
postgresimage (version12-alpine).
Debugging
Something went wrong? Check the logs:
docker logs [container_name_or_id]
# Follow logs in real-time
docker logs -f [container_name_or_id]