Docker : A quick reference commands

Docker is a containerization system which packages and runs the application with its dependencies inside a container.  In this post, I will share with you 10 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 <image name> 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 <image name> 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 know. If the image is not present locally, docker first pulls the image and runs it
  5. docker ps docker ps command lists all the docker containers that 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 info Get detailed information about docker installed on the system including the kernel version, number of containers and images, etc.
  10. docker search Search for a docker image on dockerhub with the name mentioned in the command.
  11. docker system df  Check disk space being used by your containers
  12. docker cp container-name:/file/path /host/path Copy file from container to host 
  13. docker cp /host/file/path container-name:/path/ Copy file from host to container 
  14. docker volume rm volume-name Remove a Docker volume 
  15. docker network rm network-name Remove a Docker network 
  16. docker container run -it image-name /bin/bash Run a container in interactive mode 
  17. docker container rename oldname newname Rename a container
  18. docker inspect -f “{{ .NetworkSettings.IPAddress }}” container-name Check the IP of a container 
  19. docker ps -qa List all container by their ID 
  20. docker exec -it container-name /bin/bash SSH into a container 

Enjoy

Leave a Reply

Your email address will not be published. Required fields are marked *