🐳 Getting Started with Docker

If you’ve ever struggled to make your app “run on my machine” but not on someone else’s, then Docker is here to save the day. It’s one of the most powerful tools for developers today, enabling consistent, isolated, and portable environments across development, testing, and production.
In this post, we’ll go over what Docker is, why it’s useful, and how to get started step by step.
🚀 What is Docker?
At its core, Docker is a platform that lets you package your application and all its dependencies into a container — a lightweight, standalone unit that can run anywhere.
Think of a container as a portable mini-computer that includes your code, runtime, libraries, and system tools — everything your app needs to work perfectly.
In short:
A container = your app + everything it needs
A Docker image = blueprint to create containers
Docker Engine = runs and manages your containers
⚙️ Why Use Docker?
Here’s why developers love Docker:
🧩 Consistency — no more “works on my machine” issues.
🚢 Portability — run your app anywhere (Mac, Windows, Linux, Cloud).
⚡ Speed — containers start up in seconds.
💰 Efficiency — use fewer resources than full virtual machines.
🔁 Version Control for Environments — recreate environments with a single file (
Dockerfile).
🧰 Installing Docker
Step 1: Download and Install Docker Desktop
Head over to Docker’s official website and download Docker Desktop for your OS (Windows, macOS, or Linux).
After installation, verify Docker is running by opening your terminal and typing:
docker --version
You should see something like:
Docker version 27.0.1, build c8c43
🧱 Your First Docker Container
Let’s run your first container!
docker run hello-world
This command:
Pulls a small image called
hello-worldfrom Docker Hub.Creates a container from it.
Runs it, printing a friendly greeting.
🎉 Congratulations! You just ran your first Docker container.
📝 Building Your First Docker Image
Now let’s containerize a simple app.
Create a file called app.py:
print("Hello from inside Docker!")
Then create a Dockerfile in the same directory:
# Use an official Python runtime
FROM python:3.11-slim
# Set the working directory
WORKDIR /app
# Copy the current directory into the container
COPY . .
# Command to run your app
CMD ["python", "app.py"]
Now build the image:
docker build -t hello-docker .
And run it:
docker run hello-docker
Boom! You’ve containerized your first Python app 🚀
🧭 Understanding Docker Hub
Docker Hub is like GitHub for Docker images.
You can:
Pull existing images (
docker pull nginx)Push your own images
Browse public repositories
Example:
docker pull redis
docker run -d -p 6379:6379 redis
🧩 Common Docker Commands
| Command | Description |
docker ps | List running containers |
docker ps -a | List all containers (including stopped) |
docker images | List available images |
docker stop <id> | Stop a running container |
docker rm <id> | Remove a container |
docker rmi <id> | Remove an image |
🧠 Pro Tip: Docker Compose
When your project grows and has multiple services (say, web + database + cache), use Docker Compose.
It lets you define and run multi-container apps with a simple YAML file.
Example docker-compose.yml:
version: '3'
services:
web:
image: nginx
ports:
- "8080:80"
db:
image: postgres
environment:
POSTGRES_PASSWORD: example
Run everything with one command:
✅ Wrapping Up
Docker simplifies development and deployment by giving your apps consistent environments — everywhere.
You’ve now learned:
What Docker is
How to install it
How to build and run containers
Basics of Docker Hub and Docker Compose
From here, try:
Containerizing one of your existing apps
Exploring Docker Compose
Publishing your image to Docker Hub
If you found this helpful, drop a ❤️ on Hashnode and share it with your fellow developers!
Hyperlink