20 Docker commands That must be in your cheat sheet.
These commands will help you in the DevOps interview or even easy environment setup.
In comparison to the traditional virtualization functionalities of hypervisors,
Docker containers eliminate the need for a separate guest operating system for every new virtual machine.
Docker implements a high-level API to provide lightweight containers that run processes in isolation.
A Docker container enables rapid deployment with minimum run-time requirements. It also ensures better management and simplified portability.
This helps developers and operations teams in the rapid deployment of an application.
We should be comfortable with four terms
1) Docker Images
Combinations of binaries/libraries which are necessary for one software application.
2) Docker Containers
When an image is executed and comes into running condition, it is called a container.
3) Docker Host
The machine on which the docker is installed is called a Docker host.
4) Docker Client
Terminal used to run docker run commands ( Git bash )
Docker Commands
— — — — — — — — — —
Working on Images:
— — — — — — — — — — — — -
1 To download a docker image
docker pull image_name
2 To see the list of docker images
docker image ls
(or)
docker images
3 To delete a docker image from the docker host
docker rmi image_name/image_id
4) To upload a docker image into the docker hub
docker push image_name
5) To tag an image
docker tag image_name ipaddress_of_local_registry:5000/image_name
6) To build an image from a customized container
docker commit container_name/container_id new_image_name
7) To create an image from the docker file
docker build -t new_image_name
8) To search for a docker image
docker search image_name
9) To delete all images that are not attached to containers
docker system prune -a
Working on containers
— — — — — — — — — — — — — — -
10) To see the list of all running containers
docker container ls
11) To see the list of running and stopped containers
docker ps -a
12) To start a container
docker start container_name/container_id
13) To stop a running container
docker stop container_name/container_id
14) To restart a running container
docker restart container_name/container_id
To restart after 10 seconds
docker restart -t 10 container_name/container_id
15) To delete a stopped container
docker rm container_name/container_id
16) To delete a running container
docker rm -f container_name/container id
17) To stop all running containers
docker stop $(docker ps -aq)
18) To restart all containers
docker restart $(docker ps -aq)
19) To remove all stopped containers
docker rm $(docker ps -aq)
20) To remove all containers(running and stopped)
docker rm -f $(docker ps -aq)
Thank you for the read.
If you like the post clap for me, follow me
and subscribe for the email notification for future docker posts.