Docker is a containerization system which packages and runs the application with its dependencies inside a container. In this article, I mentioned about 15 Docker Commands you need to know while working with Docker.
1. docker --version
One of the first things we all want to know is how to find the installed docker version.
2. docker pull
The 'docker pull' is a Docker command to download a Docker image or a repository locally on the host from a public or private registry.
3. docker images
List all the docker images pulled on the system with image details such as TAG/IMAGE ID/SIZE etc.
4. docker run
The docker run command creates a container from a given image and starts the container using a given command. It is one of the first commands you should become familiar with when starting to work with Docker.
If the image is not present locally, docker first pulls the image from the repository and runs it.
5. docker ps
docker ps command lists all the docker containers are running with container details. To list all the docker containers running/exited/stopped with container details, we use docker ps -a
command
6. docker start/ stop/restart
docker start command in docker starts the docker container with container id mentioned in the command.
docker stop stops a container with container id mentioned in the command.
To restart the docker container, we use docker restart.
7. docker rm
Remove the docker container with container id mentioned in the command.
8. docker rmi
Remove the docker image with the docker image id mentioned in the command
9. docker commit
Create a new image from a container’s changes. It can be useful to commit a container’s file changes or settings into a new image.
10. docker login
Login into docker hub. You will be asked your docker hub credentials to log in.
I already had my credentials setup, so it didn't ask me to enter login id and password. 11. docker push
Upload a docker image with the image name mentioned in the command on the dockerhub.
Once it is successful, you would be able to see the docker image in your docker hub repo.
12. docker info
Get detailed information about docker installed on the system including the kernel version, number of containers and images, etc.
13. docker history
Shows the history of a docker image with the image name mentioned in the command.
14. docker search
Search for a docker image on dockerhub with the name mentioned in the command.
15. docker logout
Logging out from dockerhub.