Guest User

Untitled

a guest
Mar 24th, 2018
112
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.16 KB | None | 0 0
  1. ## List Docker CLI commands
  2. docker
  3. docker container --help
  4.  
  5. ## Display Docker version and info
  6. docker --version
  7. docker version
  8. docker info
  9.  
  10. ## Excecute Docker image
  11. docker run hello-world
  12.  
  13. ## List Docker images
  14. docker image ls
  15.  
  16. ## List Docker containers (running, all, all in quiet mode)
  17. docker container ls
  18. docker container ls --all
  19. docker container ls -a -q
  20.  
  21. docker build -t friendlyhello . # Create image using this directory's Dockerfile
  22. docker run -p 4000:80 friendlyhello # Run "friendlyname" mapping port 4000 to 80
  23. docker run -d -p 4000:80 friendlyhello # Same thing, but in detached mode
  24. docker container ls # List all running containers
  25. docker container ls -a # List all containers, even those not running
  26. docker container stop <hash> # Gracefully stop the specified container
  27. docker container kill <hash> # Force shutdown of the specified container
  28. docker container rm <hash> # Remove specified container from this machine
  29. docker container rm $(docker container ls -a -q) # Remove all containers
  30. docker image ls -a # List all images on this machine
  31. docker image rm <image id> # Remove specified image from this machine
  32. docker image rm $(docker image ls -a -q) # Remove all images from this machine
  33. docker login # Log in this CLI session using your Docker credentials
  34. docker tag <image> username/repository:tag # Tag <image> for upload to registry
  35. docker push username/repository:tag # Upload tagged image to registry
  36. docker run username/repository:tag # Run image from a registry
  37.  
  38. docker stack ls # List stacks or apps
  39. docker stack deploy -c <composefile> <appname> # Run the specified Compose file
  40. docker service ls # List running services associated with an app
  41. docker service ps <service> # List tasks associated with an app
  42. docker inspect <task or container> # Inspect task or container
  43. docker container ls -q # List container IDs
  44. docker stack rm <appname> # Tear down an application
  45. docker swarm leave --force # Take down a single node swarm from the manager
  46.  
  47. docker-machine create --driver virtualbox myvm1 # Create a VM (Mac, Win7, Linux)
  48. docker-machine create -d hyperv --hyperv-virtual-switch "myswitch" myvm1 # Win10
  49. docker-machine env myvm1 # View basic information about your node
  50. docker-machine ssh myvm1 "docker node ls" # List the nodes in your swarm
  51. docker-machine ssh myvm1 "docker node inspect <node ID>" # Inspect a node
  52. docker-machine ssh myvm1 "docker swarm join-token -q worker" # View join token
  53. docker-machine ssh myvm1 # Open an SSH session with the VM; type "exit" to end
  54. docker node ls # View nodes in swarm (while logged on to manager)
  55. docker-machine ssh myvm2 "docker swarm leave" # Make the worker leave the swarm
  56. docker-machine ssh myvm1 "docker swarm leave -f" # Make master leave, kill swarm
  57. docker-machine ls # list VMs, asterisk shows which VM this shell is talking to
  58. docker-machine start myvm1 # Start a VM that is currently not running
  59. docker-machine env myvm1 # show environment variables and command for myvm1
  60. eval $(docker-machine env myvm1) # Mac command to connect shell to myvm1
  61. & "C:\Program Files\Docker\Docker\Resources\bin\docker-machine.exe" env myvm1 | Invoke-Expression # Windows command to connect shell to myvm1
  62. docker stack deploy -c <file> <app> # Deploy an app; command shell must be set to talk to manager (myvm1), uses local Compose file
  63. docker-machine scp docker-compose.yml myvm1:~ # Copy file to node's home dir (only required if you use ssh to connect to manager and deploy the app)
  64. docker-machine ssh myvm1 "docker stack deploy -c <file> <app>" # Deploy an app using ssh (you must have first copied the Compose file to myvm1)
  65. eval $(docker-machine env -u) # Disconnect shell from VMs, use native docker
  66. docker-machine stop $(docker-machine ls -q) # Stop all running VMs
  67. docker-machine rm $(docker-machine ls -q) # Delete all VMs and their disk images
Add Comment
Please, Sign In to add comment