Docker: Essential Commands Every Developer Should Know
Natan Ferreira- 0
- 446
Docker has revolutionized the way developers package, distribute, and run applications. With it, you can create portable and standardized environments with incredible ease. To make the most of this powerful tool, it’s essential to master some basic commands that are part of daily work with containers, images, and networks. In this post, we’ll explore the key Docker commands, explaining what they do and giving practical examples so you can immediately apply them to your workflow.

🔍 Searching on DockerHub
docker search: allows you to search images on DockerHub. You can view available options using the command below:
docker search --help
For example, to search for a Node image:
docker search node
✅ Verifying Docker Is Working
docker --version
docker info
📥 Downloading an Image
docker pull nginx
nginx is a popular image available on DockerHub.
🚀 Running a Container
Basic run:
docker run nginx
You can also specify a name for the container:
docker run --name server nginx
Running in Detached Mode
docker run -d nginx
The detached mode in Docker allows you to run a container in the background, meaning it keeps running independently of your terminal.
Run and map a port:
docker run -d -p 8080:80 nginx
Here, 8080 is the port on your machine (host), and 80 is the internal port of the container.
📋 Listing Containers
Running containers only:
docker ps
All containers (including stopped):
docker ps -a
🛑 Stopping and Removing Containers
Stop a container:
docker stop <container_id>
Remove a container:
docker rm <container_id>
You can use the container’s name instead of the ID.
docker rm <container_name>
📦 Listing Downloaded Images
docker images
❌ Removing an Image
docker rmi <image_id>
📄 Viewing Container Logs
docker logs <container_id>
🧹 Cleaning Up Resources
Remove all stopped containers, unused networks, dangling images, and build cache:
docker system prune
Conclusion
Mastering the essential Docker commands is a fundamental step for anyone looking to build modern, scalable, and portable applications. From building an image to running and managing containers, each command gives you more control and efficiency in both development and production. With practice and curiosity, you’ll be able to set up complex environments with ease, reduce errors, and boost productivity. Keep exploring and deepening your knowledge to make the most of this powerful container platform.
Author
-
I am a seasoned Full Stack Software Developer with 8+ years of experience, including 6+ years specializing in Java with Spring and Quarkus. My core expertise lies in developing robust RESTful APIs integrated with Cosmos Db, MySQL, and cloud platforms like Azure and AWS. I have extensive experience designing and implementing microservices architectures, ensuring performance and reliability for high-traffic systems.
In addition to backend development, I have experience with Angular to build user-friendly interfaces, leveraging my postgraduate degree in frontend web development to deliver seamless and responsive user experiences. My dedication to clean and secure code led me to present best practices to my company and clients, using tools like Sonar to ensure code quality and security.
I am a critical thinker, problem solver, and team player, thriving in collaborative environments while tackling complex challenges. Beyond development, I share knowledge through my blog, NatanCode, where I write about Java, Spring, Quarkus, databases, and frontend development. My passion for learning and delivering innovative solutions drives me to excel in every project I undertake.
View all posts