Docker Commands with Examples
In this blog, I’ll talk about essential Docker Commands that you will be using frequently while you are working with Docker.
docker --version
This command is used to get the currently installed version of docker docker pull
Usage: docker pull [image name]
This command is used to pull images . Docker looks for this image on our local system. When it can’t find the image, Docker downloads it from Docker Hub for us.
docker run
Usage: docker run -it -d [image name]
This command is used to create a container from an image
docker ps
This command is used to list the running containers
docker ps -a
This command will show all the containers both stopped and running.
docker images
This command lists all the docker images.
docker rm
Usage: docker rm [container id]
This command is used to delete a stopped container. (First stop the container before delete it. Because running container cant be delete )
docker rmi
Usage: docker rmi [image id]
This command is used to delete a image.
docker stop
Usage: docker stop [container id] or docker container stop [container id]
This command stops a running container.
docker build
Usage: docker build [path to docker file]
The docker build command builds Docker images from a Dockerfile