Table of Contents
docker -version
This command is used to get the docker version currently installed.
docker login
This command is used to login into the docker hub repository. It will ask you for the username and password as you enter the command.
docker pull
This command is used to pull docker images from the docker repository (hub.docker.com). A pull command forces an image to download, whether it is already present in local or not.
Usage :- docker pull <imageName>
Example :- docker pull mysql
docker push
This command pushes an image to the docker hub repository.
Usage :- docker push <username/imageName>
Example :- docker push myaccountName/my-spring-boot-app
docker run
This command is used to create a container from an image.
Usage :- docker run -it -d <imageName>
Example :- docker run -it -d ubuntu
docker commit
When you make any changes inside any file in the container, then we can commit the changes. When you commit the container, a new image is created and you can push that image to the registry. Anybody can fetch the image and will have the same code with a consistent environment. This also helps in deployment as well.
Usage :– docker commit -m “<commit message>” <container_id/name> <new_image_name>:<version>.
docker ps
This command lists the containers that have stopped.
docker ps -a
This command shows all the running, exited and stopped containers.
docker images
This command shows all the docker images stored locally.
docker stop
This command is used to stop the running container.
Usage :- docker stop <containerId>
docker kill
This command stops the execution of the container immediately. The difference between docker stop and docker kill command is that, the later stops the container abruptly, whereas the former stops the container gracefully.
Usage :- docker kill <containerId>
docker rm
remove/delete the docker container with the container id mentioned.
Usage :- docker rm <containerId>
docker rmi
remove/delete the docker image from local storage, with the docker image id mentioned.
Usage :- docker rmi <containerId>
docker container prune -f
This is the equivalent of running one docker rm command for each stopped container. The -f switch is an implicit confirmation to proceed and delete all stopped containers right away, instead of asking to confirm that operation.
docker image prune -f
his is the equivalent of running one docker rmi command for each image. The -f switch is an implicit confirmation to proceed and delete all images right away, instead of asking to confirm that operation.
docker exec
This command is used to run commands inside the docker container
Usage :- docker exec -t <containerId> bash
docker restart
This command is used to restart the docker container.
Usage :- docker restart <containerId>
docker start
This command is used to start the docker container.
Usage :- docker start <containerId>
docker info
Using this command we can get the metadata information like kernel version, number of containers , no of running containers etc.
docker history
Shows the history of the docker image
Usage :- docker history <imageName>
docker logs
This command will show the container logs of the container id provided. It retrieves the logs of a container, even when it has stopped. The “docker logs” command outputs exactly the same text you saw when you ran the container. This is the standard output of the container.
Usage :- docker logs <containerId>
docker inspect
This command gets the detailed information about a running or stopped container. The “docker inspect” command gets you an abundance of information about many aspects of the container – whether it is still running or stopped.
Usage :- docker inspect <containerId>
docker volume
This command will create a volume which will be used by the docker container to store data .
docker stats
High availability Docker servers are monitored with tools that are up to the tasks such as collecting your logs and providing usage statistics. It will list the live running containers and information on how many resources they are consuming on the host machine. Like a docker ps extended with live resource usage data.
docker volume create
This command is used to create a new volume.
Usage: docker volume create <volume_name>
docker inspect volume
This command is used to inspect the created volume.
docker run -v
This command is used to mount a volume.
Leave a Reply