Most Commonly Used Docker Commands!
Srikanth Jana
Posted on October 29, 2024
Hello Everyone!
In this simple blog we will see most commonly used docker commands in our day to day work.
docker ps:
The 'docker ps' command is used to list all the running containers on your Docker host. By default, it shows a summary of the containers that are currently up, including their container IDs, image names, command being run, creation time, status, ports, and names.
If you want to see all containers, including those that are stopped, you can use:
docker ps -a
docker images:
The docker images command lists all the Docker images stored on your local machine.
docker images
docker stop:
The docker stop command is used to stop a running container. You can specify the container by its name or ID.
docker stop <conainerID/name>
docker start:
The docker start command is used to start one or more stopped containers. It takes a container ID or name as an argument and will resume the container from where it was last stopped.
docker start <containerId/name>
docker restart:
The docker restart command is used to stop and then start a running container in one command.
doccker restart <containerID/name>
docker rmi:
The docker rmi command is used to remove one or more Docker images from your local machine. This can help free up disk space or clean up images that are no longer needed.
docker rmi <imageId or Name>
If the image is being used by any stopped containers or other images, you'll need to use the -f (force) option:
docker rmi -f <imageId or Name>
docker container prune:
You can use the docker container prune command to remove only stopped containers in Docker. This command will remove all containers that are not currently running.
docker container prune
docker image prune:
The docker image prune command is used to remove unused Docker images.
docker image prune
docker inpect:
The docker inspect command is used to retrieve detailed information about a Docker object, such as containers, images, networks, or volumes
docker inspect <containerId/name>
docker stats:
The docker stats command provides real-time metrics for running containers, displaying resource usage statistics such as CPU, memory, network I/O, and disk I/O.
To view real-time stats for all running containers:
docker stats
display stats for specific containers:
docker stats <containerId/name>
Posted on October 29, 2024
Join Our Newsletter. No Spam, Only the good stuff.
Sign up to receive the latest update from our blog.