Advertisement
Guest User

Untitled

a guest
Aug 23rd, 2019
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.33 KB | None | 0 0
  1. ## Remove all images & containers
  2.  
  3. ```
  4. docker rmi $(docker images -a -q)
  5. docker container rm $(docker container ls -aq)
  6. docker container prune
  7. ```
  8. ## Stop all containers
  9. ``` docker container stop $(docker container ls -aq) ```
  10.  
  11. ## Get information about container
  12. ``` docker inspect <container-name> ```
  13.  
  14. ## Running Nginx container
  15. ``` docker container run -d -p 8000:80 --name nginx nginx ```
  16.  
  17. * -d (detach) - releases console for further use
  18. * -publish (or -p) is a way of mapping a host port to a running container port
  19. * 8000 - port to run localhost and port 80 for Nginx server
  20. * --name nginx - giving alias `nginx` for a container
  21.  
  22. # ACCESSING CONTAINERS
  23.  
  24. ## Create new nginx container and bash into
  25. ``` docker container run -it --name <NAME> nginx bash ```
  26. * i = interactive Keep STDIN open if not attached
  27. * t = tty - Open prompt
  28.  
  29. For Git Bash, use "winpty"
  30.  
  31. ``` $ winpty docker container run --rm -it container-name bash ```
  32.  
  33. ## Access running container
  34. ``` docker exec -it <container-name> bash ```
  35.  
  36. ## Build container compose file and execute all configuration
  37. ``` docker-compose build ```
  38.  
  39. ## Build Dockerfile
  40. ``` docker build -t my-container . ```
  41. * -t - container name
  42.  
  43.  
  44. ## Start container
  45. ``` docker-compose up ```
  46. issue command inside dir where Dockerfile is located
  47.  
  48. ## Docker Volume
  49. ``` docker run -v `pwd`:/data -it my-container ```
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement