Getting Started with Docker: Basic Commands for Beginners

Introduction
In modern development, Docker has become a must-know tool for developers, DevOps engineers, and anyone working with code. It lets you package your applications into containers — lightweight, isolated environments that run anywhere.
If you're just starting out, learning Docker can feel a little overwhelming. But once you understand a few basic commands, you'll be ready to run your first container and manage your environment easily.
In this blog, I’ll walk you through the basic Docker commands I learned today. No jargon, just simple explanations and examples.
What is Docker? (In simple words)
Docker is a tool that helps you run applications in isolated containers. Think of it as a box where everything needed to run your app — code, libraries, dependencies — is packed. This makes it easy to run the same app anywhere without compatibility issues.
Installing Docker
Before you begin, make sure Docker is installed on your system.
Basic Docker Commands You Must Know
1. Check Docker version
docker --version
✅ Checks if Docker is installed and running.
2. Pull an Image
docker pull <image_name>
Example:
docker pull nginx
✅ Downloads the Nginx image from Docker Hub.
3. Run a Container
docker run <image_name>
Example:
docker run -d -p 8080:80 nginx
✅ Runs the Nginx server in detached mode and maps port 8080 on your system to port 80 in the container.
4. List Running Containers
docker ps
✅ Displays all running containers.
To list all containers (including stopped ones):
docker ps -a
5. Stop a Running Container
docker stop <container_id>
✅ Stops the container gracefully.
6. Remove a Container
docker rm <container_id>
✅ Deletes a stopped container.
7. List All Images
docker images
✅ Shows all images downloaded on your system.
8. Remove an Image
docker rmi <image_id>
✅ Deletes an image from your local system.
Running Your First Web Server with Docker
Let’s run a simple web server using Nginx:
docker run -d -p 8080:80 nginx
👉 Now, open your browser and go to http://localhost:8080
— You’ll see the Nginx welcome page!
Docker Command Cheat Sheet (Save this!)
Command | Description |
docker --version | Check Docker version |
docker pull <image> | Download image from Docker Hub |
docker run <image> | Run a container from an image |
docker ps | List running containers |
docker stop <container_id> | Stop a container |
docker rm <container_id> | Remove a stopped container |
docker images | List all downloaded images |
docker rmi <image_id> | Delete an image |
Conclusion
Docker might seem intimidating at first, but once you start using these basic commands, you’ll realize how powerful and easy it is. It helps you manage apps and services without worrying about dependencies or setup conflicts.
This blog is just the beginning — soon, you’ll be building custom Dockerfiles, using Docker Compose, and deploying full-stack applications!
Subscribe to my newsletter
Read articles from Rahul Kapoor directly inside your inbox. Subscribe to the newsletter, and don't miss out.
Written by
