Docker Command¶
Note
For documentation about writing images see: Dockerfile examples and best practices
attach vs exec¶
When wanting to execute something inside a container, you can use either of docker attach ...
or docker exec -it ...
commands
The main difference between these two commands is that attach
will kill PID 1 when you disconnect from your container.
The exec
command do not kill PID 1, so your container will continue running
Print all digest with full sha1¶
docker images --digests
Print only ids¶
docker images ... -q
Filter images¶
docker images --filter=reference='registry/*'
docker images --filter=reference='registry/*/*'
docker images --filter=reference='registry/*/*/*'
Format output to get repository:tag¶
Available: .ID, .Repository, .Tag, .Digest, .CreatedSince, .CreatedAt, Size
docker images --filter=reference='registry/*/*/*' --format "{{.Repository}}:{{.Tag}}"
Push all filtered images¶
for i in $(docker images --filter=reference='registry/*/*/*' --format "{{.Repository}}:{{.Tag}}"); do docker push $i; done
Find containers folder name¶
sudo su -
for f in `find /var/lib/docker -name 'config.v2.json'`; do echo $f; cat $f | python -m json.tool | grep '"Name": "/r'; done | grep <application_name>