Basic Docker Commands

yum install docker -y
Installs Docker using theyum
package manager on Linux.docker --version
Displays the installed Docker version.service docker start
Starts the Docker service on your system.service docker status
Checks if the Docker service is running or not.docker info
Shows detailed information about the Docker system, including configuration and stats.docker images
Lists all Docker images available locally on your machine.docker search <image_name>
Searches for an image on Docker Hub based on the given name.docker pull <image_name>
Downloads an image from Docker Hub to your local machine.docker run -itd --name <container_name> -p <host_port>:<container_port> <image_name>
Runs a container with a custom name and maps ports between the host and container.docker start <container_name_or_id>
Starts a stopped container.docker attach <container_name>
Attaches your terminal to a running container.cat /etc/os-release
Shows the operating system details inside the container.exit
Exits the container and returns to your host machine’s terminal.docker ps -a
Lists all containers (running and stopped).docker ps
Shows only running containers.docker ps -q -f "state=exited"
Lists only containers that have exited.docker stop <container_name_or_id>
Stops a running container.docker rm <container_name_or_id>
Removes a stopped container from your system.docker stop $(docker ps -a -q)
Stops all containers, whether they are running or not.docker rm $(docker ps -a -q)
Removes all stopped containers from your system.docker rmi -f $(docker images -q)
Deletes all Docker images from your system.
Conclusion:
In this blog, we’ve covered some of the most fundamental Docker commands that every beginner should know. These commands are essential for managing Docker images, containers, networks, and volumes. Whether you’re pulling images, running containers, or cleaning up your system, mastering these basic commands will give you a strong foundation for working with Docker.
As you continue your Docker journey, you’ll discover more advanced commands and configurations. But understanding and practicing these basics will make it easier to dive deeper into Docker’s capabilities. Happy Dockerizing!
"Thanks for reading! If you found this helpful, leave a comment, share with your friends & follow me for more simple DevOps & Docker tips. Happy Learning! ❤️"
Subscribe to my newsletter
Read articles from Anusha Kotha directly inside your inbox. Subscribe to the newsletter, and don't miss out.
Written by
