Docker has revolutionized the way developers build, ship, and run applications. With containerization, you can ensure that your apps run consistently across different environments. Whether youโre a beginner or an experienced developer, knowing key Docker commands will make your workflow faster and more efficient!
Let’s dive into some essential Docker commands that will supercharge your container management skills. ๐ก๐ฅ

๐ข 1. Running a Container Based on an Image
To launch a container from an image, run:
docker run --name NAME --rm -d -p 5001:8080 image
๐ก Breaking it down:
- ๐ท๏ธ
--name NAME: Gives your container a custom name. - ๐๏ธ
--rm: Deletes the container automatically when stopped. - ๐
-d: Runs the container in detached mode (background). - ๐
-p 5001:8080: Maps port 5001 on your machine to port 8080 inside the container.
๐ 2. Building an Image from a Dockerfile
To create a Docker image from a Dockerfile in your current directory:
docker build -t name:tag .
๐ก What’s happening here?
- ๐จ
-t name:tag: Assigns a name and version to your image. - ๐
.(dot): Specifies that the current directory is the build context.
๐ง 3. Inspecting and Removing Docker Images
๐ To inspect an image (see details like size, layers, and config):
docker image inspect name/id
๐ To delete an image you no longer need:
docker rmi name/id
โก To clean up ALL unused images and free up space:
docker image prune -a
๐ฆ 4. Pulling and Pushing Docker Images
๐ฅ Download (pull) an image from Docker Hub:
docker pull name:tag
๐ค Upload (push) an image to Docker Hub or another registry:
docker push REPOSITORY/NAME:TAG
โ 5. Managing Containers Like a Pro
โจ To create a new container (without starting it immediately):
docker create imagename
โน๏ธ To stop a running container:
docker stop containername
โถ๏ธ To restart a stopped container:
docker start containername
๐ To remove a specific container:
docker rm containername
๐ฅ To clean up all stopped containers at once:
docker container prune
๐ฏ Conclusion: Become a Docker Pro!
By mastering these must-know Docker commands, youโll:
โ
Speed up your development workflow ๐
โ
Keep your system clean & optimized ๐งน
โ
Manage containers like a pro ๐ช
๐ก Want to dive deeper? Keep practicing, experiment with different commands, and explore Dockerโs vast capabilities!
๐ข Happy Docker-ing! ๐