List of Docker Commands

  1. To display list of docker container
    • docker ps  
  2. To start the service of docker 
    • service docker start
  3. to get the list of docker images
    • docker image ls
  4. To pull the docker images like docker pull <image-name:tag-no>
    • docker pull tomcat:latest
  5. To create the docker container from docker tomcat image 
    • docker run —name tomcat-container -p 8080:8080 tomcat:latest 
  6. To get the list of container those are in stopped/running stages 
    • docker ps -a
  7. To remove the docker container with the help of docker container id 
    • docker rm <container -id>  
  8. To create the docker container from docker tomcat image  – It’s in detach mode
    • docker run -d —name tomcat-container -p 8080:8080 tomcat:latest
  9. To stop the docker container
    • docker stop <container-id>
  10. To login into the docker and go inside to check the issue of docker access from browser 
    • docker exec -it tomcat-container /bin/bash 
    • docker exec -it <container-id> /bin/bash 
  11. To create docker image with the help of Dockerfile 
    • docker build -t devops-project
  12. To remove the docker image
    • docker rmi <repository>
  13. If you want docker will on boot on your machine automatically:
    • docker chkconfig docker on
  14. Remove all unused containers, networks, images (both dangling and unreferenced), and optionally, volumes.
    • docker system prune
  • 23
    Shares