P
Home Articles Poems, Wishes Recipes
Menu
×

Best Docker Commands to Simplify Your Dev Workflow

Docker makes it easy to run, test, and deploy applications in isolated environments, which is why it's a go-to tool for developers and DevOps teams. With just a few commands, you can launch containers, connect services, and manage your entire development setup. Whether you're building microservices, testing locally, or managing CI/CD pipelines, Docker simplifies your daily tasks. Learning a handful of practical commands can save you hours of manual configuration. These commands become especially valuable when switching between projects, sharing environments, or troubleshooting. If you're tired of the classic “it works on my machine” problem, Docker provides a fast and consistent solution. Below is a curated list of must-know Docker commands that will boost your efficiency every day.


Managing Containers

Containers are the core of Docker, and knowing how to manage them is critical:

  • docker ps – Shows running containers. Use -a to list all (including stopped) containers.
  • docker start <container> – Starts a stopped container.
  • docker stop <container> – Gracefully stops a running container.
  • docker restart <container> – Restarts a container.
  • docker rm <container> – Removes a container. Use -f to force removal.

Working with Images

Images are the blueprint for containers, and these commands help manage them:

  • docker pull <image> – Downloads an image from Docker Hub or a private registry.
  • docker images – Lists all locally available images.
  • docker rmi <image> – Removes a specific image from your system.
  • docker build -t <tag> . – Builds an image from a Dockerfile in the current directory.

Running and Executing Inside Containers

For testing, debugging, or running apps, you’ll often use these:

  • docker run -it <image> /bin/bash – Starts a container interactively with a shell.
  • docker exec -it <container> /bin/bash – Opens a shell inside a running container.
  • docker logs <container> – Displays output logs from a container.

Volumes and Data Management

Persistent data is important for stateful applications:

  • docker volume ls – Lists all volumes.
  • docker volume create <name> – Creates a new volume.
  • docker run -v <volume>:/path/in/container – Mounts a volume into the container.

Docker Networks

Networking helps containers talk to each other or to the host:

  • docker network ls – Shows available networks.
  • docker network create <name> – Creates a custom network.
  • docker run --network=<name> – Runs a container on a specific network.

Clean-Up and Maintenance

To avoid unnecessary disk usage and clutter:

  • docker system prune – Removes unused data (containers, networks, dangling images).
  • docker container prune – Removes stopped containers.
  • docker image prune – Cleans up unused images.

Conclusion

Mastering these commonly used Docker commands helps you maintain an efficient and organized development workflow. Regular use of these will keep your local environment clean, fast, and predictable.