Docker Basics for DevOps: Practical Usage and Essential Commands

Docker has become a standard tool in every DevOps engineer’s toolkit. Whether you’re building microservices or deploying scalable containers, understanding how Docker works — and how to use it efficiently — is essential.

In this blog, we’ll explore what Docker is, how it helps DevOps workflows, and go through the most commonly used Docker commands with examples.


🐳 What is Docker?

Docker is an open-source platform that allows developers and DevOps engineers to package applications into containers — lightweight, standalone, and executable units that include everything the app needs to run.

Instead of “it works on my machine,” with Docker, it works everywhere — from your laptop to production.


🔧 Why Use Docker in DevOps?

✅ Portability: Containers run the same on every environment
✅ Speed: Build and deploy apps faster
✅ Isolation: Each container runs in its own environment
✅ CI/CD Ready: Ideal for automated pipelines


🛠️ Essential Docker Commands

Here are the most commonly used Docker commands you’ll use daily:


🔹 1. Check Docker Version

docker --version

🔹 2. Pull an Image from Docker Hub

docker pull nginx

This downloads the latest official Nginx image.


🔹 3. List Available Docker Images

docker images

🔹 4. Run a Container

docker run -d -p 8080:80 nginx

Runs Nginx in detached mode, mapping port 80 inside the container to port 8080 on your system.


🔹 5. List Running Containers

docker ps

Use docker ps -a to see all (including stopped) containers.


🔹 6. Stop a Container

docker stop <container_id>

🔹 7. Remove a Container

docker rm <container_id>

🔹 8. Build a Docker Image from Dockerfile

docker build -t myapp:1.0 .

This command builds a Docker image with a tag myapp:1.0.


🔹 9. Tag and Push Image to Docker Hub

docker tag myapp:1.0 yourdockerhub/myapp:1.0
docker push yourdockerhub/myapp:1.0

🔹 10. View Logs from a Running Container

docker logs <container_id>

📁 Bonus: Dockerfile Example

Here’s a simple Dockerfile for a Node.js app:

FROM node:18

WORKDIR /app

COPY package*.json ./
RUN npm install

COPY . .

CMD ["npm", "start"]

🚀 Real-Life DevOps Use Case

Let’s say you’re deploying a Python Flask app. With Docker, you:

  1. Package the app with all dependencies
  2. Build an image and push to Docker Hub
  3. Deploy that image using Jenkins, ECS, or Kubernetes

Result: No “dependency hell” across dev, QA, or prod.


🧠 Conclusion

Docker is essential for DevOps engineers. With just a few commands, you can build, test, deploy, and scale apps in seconds.

In the next blog, we’ll explore Docker Compose to manage multi-container applications easily.


🔗 Internal Links


🔗 External Links

Leave a Comment

Your email address will not be published. Required fields are marked *