mirror of
https://github.com/wsargent/docker-cheat-sheet.git
synced 2025-12-17 23:50:13 +01:00
commit
506cc94899
1 changed files with 15 additions and 15 deletions
12
README.md
12
README.md
|
|
@ -478,25 +478,25 @@ Sources:
|
||||||
```
|
```
|
||||||
alias dl='docker ps -l -q'
|
alias dl='docker ps -l -q'
|
||||||
docker run ubuntu echo hello world
|
docker run ubuntu echo hello world
|
||||||
docker commit `dl` helloworld
|
docker commit $(dl) helloworld
|
||||||
```
|
```
|
||||||
|
|
||||||
### Commit with command (needs Dockerfile)
|
### Commit with command (needs Dockerfile)
|
||||||
|
|
||||||
```
|
```
|
||||||
docker commit -run='{"Cmd":["postgres", "-too -many -opts"]}' `dl` postgres
|
docker commit -run='{"Cmd":["postgres", "-too -many -opts"]}' $(dl) postgres
|
||||||
```
|
```
|
||||||
|
|
||||||
### Get IP address
|
### Get IP address
|
||||||
|
|
||||||
```
|
```
|
||||||
docker inspect `dl` | grep IPAddress | cut -d '"' -f 4
|
docker inspect $(dl) | grep IPAddress | cut -d '"' -f 4
|
||||||
```
|
```
|
||||||
|
|
||||||
or install [jq](https://stedolan.github.io/jq/):
|
or install [jq](https://stedolan.github.io/jq/):
|
||||||
|
|
||||||
```
|
```
|
||||||
docker inspect `dl` | jq -r '.[0].NetworkSettings.IPAddress'
|
docker inspect $(dl) | jq -r '.[0].NetworkSettings.IPAddress'
|
||||||
```
|
```
|
||||||
|
|
||||||
or using a [go template](https://docs.docker.com/reference/commandline/inspect)
|
or using a [go template](https://docs.docker.com/reference/commandline/inspect)
|
||||||
|
|
@ -514,7 +514,7 @@ docker inspect -f '{{range $p, $conf := .NetworkSettings.Ports}} {{$p}} -> {{(in
|
||||||
### Find containers by regular expression
|
### Find containers by regular expression
|
||||||
|
|
||||||
```
|
```
|
||||||
for i in $(docker ps -a | grep "REGEXP_PATTERN" | cut -f1 -d" "); do echo $i; done`
|
for i in $(docker ps -a | grep "REGEXP_PATTERN" | cut -f1 -d" "); do echo $i; done
|
||||||
```
|
```
|
||||||
|
|
||||||
### Get Environment Settings
|
### Get Environment Settings
|
||||||
|
|
@ -538,7 +538,7 @@ docker ps -a | grep 'weeks ago' | awk '{print $1}' | xargs docker rm
|
||||||
### Delete stopped containers
|
### Delete stopped containers
|
||||||
|
|
||||||
```
|
```
|
||||||
docker rm -v `docker ps -a -q -f status=exited`
|
docker rm -v $(docker ps -a -q -f status=exited)
|
||||||
```
|
```
|
||||||
|
|
||||||
### Delete dangling images
|
### Delete dangling images
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue