Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ## Remove all images & containers
- ```
- docker rmi $(docker images -a -q)
- docker container rm $(docker container ls -aq)
- docker container prune
- ```
- ## Stop all containers
- ``` docker container stop $(docker container ls -aq) ```
- ## Get information about container
- ``` docker inspect <container-name> ```
- ## Running Nginx container
- ``` docker container run -d -p 8000:80 --name nginx nginx ```
- * -d (detach) - releases console for further use
- * -publish (or -p) is a way of mapping a host port to a running container port
- * 8000 - port to run localhost and port 80 for Nginx server
- * --name nginx - giving alias `nginx` for a container
- # ACCESSING CONTAINERS
- ## Create new nginx container and bash into
- ``` docker container run -it --name <NAME> nginx bash ```
- * i = interactive Keep STDIN open if not attached
- * t = tty - Open prompt
- For Git Bash, use "winpty"
- ``` $ winpty docker container run --rm -it container-name bash ```
- ## Access running container
- ``` docker exec -it <container-name> bash ```
- ## Build container compose file and execute all configuration
- ``` docker-compose build ```
- ## Build Dockerfile
- ``` docker build -t my-container . ```
- * -t - container name
- ## Start container
- ``` docker-compose up ```
- issue command inside dir where Dockerfile is located
- ## Docker Volume
- ``` docker run -v `pwd`:/data -it my-container ```
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement