# Docker CLI # Quick Commands ### Show running container ```bash docker ps ``` ### Run new container (Also pulls the corresponding image) ``` docker run -d -t -p : --name : ``` #### Docker arguments
**Argument****Meaning****Impact****Example**
-i interactiveReturns output directly to prompt from Docker docker run -i hello-world
-d detachedThe container is executed in the background docker run -d hello-world
-p portCan pass a port from the host to container (hostport:containerport) docker run -p 80:80 hello-world
-v volume mappingCan mount an external directory docker run -v /opt/datadir:/var/lib/mysql hello-world
-e environment variableThis dash can be used to pass variables to the containerdocker run -e NEW=1 hello-world
### Download specific container image ```bash docker pull : ``` ### Power options for container #### Stop container ```bash docker stop ``` #### Start container ```bash docker start ``` #### Restart Container ```bash docker restart ``` ### Show statistics ```bash docker stats ``` ### Delete all stopped container ```powershell docker system prune ``` ### Show container details ```bash docker inspect ``` #### Return specific ip address of container ```bash docker inspect -f '{{range.NetworkSettings.Networks}}{{.IPAddress}}{{end}}' ``` ### Show container logs ``` docker logs ``` #### Return logs live to console ```bash docker logs --follow ``` ### Update container restart behavior ```bash docker update --restart unless-stopped ```