Guest User

Untitled

a guest
Nov 22nd, 2017
370
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.34 KB | None | 0 0
  1. # Check if docker is running
  2. service docker.io status
  3.  
  4. # Exit container
  5. ctrl + p + q
  6.  
  7. # Docker info and docker version
  8. docker -v
  9. docker version
  10. docker info
  11.  
  12. # Add non-root to the docker group (check if it's not added first)
  13. cat /etc/group
  14. sudo gpasswd -a username docker
  15.  
  16. # Configure Docker to communicate over the network
  17. # Check programs running on the network & stop docker service
  18. netstat -tlp
  19. service docker stop
  20.  
  21. # COnfigure docker to run on IP and on UNIX
  22. docker -H IP_ADDRESS:2375 -H unix:///var/run/docker.sock -d &
  23.  
  24. # In another machine, point the deamon to the IP where docker was configured, then reset
  25. export DOCKER_HOST="tcp://IP_ADDRESS:2375"
  26. export DOCKER_HOST=
  27.  
  28. # Docker running images and were running
  29. docker ps
  30. docker ps -a
  31.  
  32. # Docker images location files
  33. /var/lib/docker/<mount>/diff/<image_id>
  34.  
  35. # Run ubuntu interactive on the terminal (-it) and run the bash process
  36. docker run -it ubuntu /bin/bash
  37.  
  38. # Run detached
  39. docker run -d ubuntu /bin/bash -c "ping 8.8.8.8 -c 30"
  40.  
  41. # See top processes inside container or inspect the information for the container
  42. docker top <hash_id>
  43. docker inspect <hash_id>
  44.  
  45. # Pull images or all tags
  46. docker pull fedora
  47. docker pull -a fedora
  48.  
  49. # Push images to the hub
  50. docker tag <image_id> user/<name_repo>
  51. docker push user/<name_repo>
  52.  
  53. # See all images (or only for one)
  54. docker images
  55. docker images fedora
  56.  
  57. # Images are stored at
  58. /var/lib/docker/<storage_driver>
  59.  
  60. # Docker start and move to container
  61. docker start <id_container>
  62. docker attach <id_container>
  63.  
  64. # Create a new docker image and save and load
  65. docker commit <hash_id> <new_image>
  66. docker save -o /tmp/<name_image> <name_image>
  67. docker load -i /tmp/<name_image>
  68.  
  69. # See history
  70. docker history <container_name>
  71.  
  72. # Docker enter container (looking inside)
  73. docker-enter <image_id>
  74.  
  75. # Execute commands inside terminal
  76. docker exec -it <image_id> /bin/bash
  77.  
  78. # Building from a Dockerfile (build)
  79. Dockerfile (<- file name)
  80. # Ubuntu based container (inside file)
  81. FROM ubuntu:17.10
  82. MAINTAINER email@example.com
  83. RUN apt-get update
  84. CMD ["echo","Hello World"]
  85. # EXPOSE 80
  86. # ENTRYPOINT ["echo"]
  87. # ADD
  88. # VOLUME /data
  89.  
  90. # Execute command to build the Dockerfile
  91. docker build -t helloworld:0.1 .
  92.  
  93. # List all containers
  94. docker ps -aq
  95.  
  96. # Stop all running containers
  97. docker stop $(docker ps -aq)
  98.  
  99. # Remove all containers
  100. docker rm $(docker ps -aq)
  101.  
  102. # Remove all images
  103. docker rmi $(docker images -q)
Add Comment
Please, Sign In to add comment