Basic Docker Commands

Learn via video courses
Topics Covered

Docker is an open-source tool that streamlines application deployment through independent, portable containers, adaptable to both local and cloud environments. This separation of applications from infrastructure facilitates swift software delivery and uniform management practices. Docker commands are pivotal in containerization, empowering developers to construct, deploy, and manage applications efficiently. By encapsulating dependencies in self-contained units, these commands ensure consistent and reliable deployment. They enhance software management, fostering shorter development cycles, scalability, and portability across diverse environments. This concise guide illuminates the significance of Docker commands, offering a comprehensive list with illustrative examples for seamless application orchestration and deployment.

Basic Docker Commands

Let's take a look at the most commonly used docker commands.

docker - version

This docker command is used to output the currently installed version and build several dockers.

Example :

docker pull

This docker command is used to pull images from a docker repository.

Example :

docker run

This docker command is used to start a docker container from a docker image.

Example :

docker ps

This docker command is used to output a list of containers currently running inside the docker engine.

Example :

docker ps -a

This docker command is used to output a list of containers currently existing inside the docker engine in the running or stopped state.

Example :

docker exec

This docker command is used to access a shell inside the running container.

Example :

docker stop

This docker command is used to stop a running container.

Example :

docker restart

This docker command is used to restart a container Example :

docker kill

This docker command is used to terminate a container immediately.

Example :

'docker kill' and 'docker stop' perform the same action of terminating a container. But, ‘docker stop’ gives the container time to shut down gracefully, whereas 'docker kill' terminates a container immediately.

docker commit

This docker command is used to create a new image of an edited container on the local system.

Example :

docker push

This docker command is used to push an image into a docker repository.

Example :

docker login

This docker command is used to login into a docker repository.

Example :

docker images

This docker command is used to list all the docker images stored on the machine.

Example :

docker rm

This docker command is used to delete a stopped container.

Example :

docker rmi

This docker command is used to delete a locally stored docker image.

Example :

docker build

This docker command is used to build a docker image based on the instructions specified in a Dockerfile.

Example :

Conclusion

We have taken a look over the most commonly used docker commands. Sound knowledge of these Docker commands will give you the needed expertise to work and experiment with Docker. So, practice them!

Let's continue learning about docker and its concepts with other docker-related articles.