Skip to content

15 docker commands that every beginner Devops Engineer should know.

Docker is a popular containerization platform that allows you to package and run applications in isolated environments called containers. Here are some commonly used Docker commands:

  1. docker version: shows installed docker version info

2. docker run: Creates and runs a container from a Docker image.

docker run [options] <image> [command]

3.docker pull: Downloads a Docker image from a registry

docker pull <image

4. docker images: Lists the Docker images available on your system.

docker images [options]

5. docker ps: Lists the running containers.

6. docker ps -a : Lists all containers.

7. docker stop: Stops one or more running containers

8. docker start: Starts one or more stopped containers.

9. docker restart: Restarts one or more containers.

docker restart [options] <container id or image name>

10. docker rm: Removes one or more containers

docker rm [options] <container>. To remove a running container, we first need to stop the contailer.

11. docker rmi: Removes one or more images. To remove an image, we first need to remove any container using that image.

12. docker exec: Execute a command in a running container

docker exec <container id> <command>

13. docker top: Display the running processes of a container.

docker top <container id>

14. get docker shell

docker exec -it <container-name-or-id> <shell-executable>
-i: interactive
-t: terminal

15. docker logs : Fetch the logs of a container

docker logs <container id>

These are few examples of commonly used Docker commands. Docker provides a wide range of commands and options to manage containers, images, networks, and volumes etc. we can explore further by using the docker --help or referring to the Docker documentation for more detailed instructions.