Tags

### To show Container information like IP address,etc2x.

docker inspect {containerId/name}

### To stop all running containers

docker stop $(docker ps -aq)

### To show log of a Container

docker logs {containerId/name}

### To delete a single Container

docker rm {containerId/name}

### To delete all Containers

docker rm $(docker ps -a -q)

### To delete a weeks ago Containers

docker ps --filter "status=exited" | grep 'weeks ago' | awk '{print $1}' | xargs --no-run-if-empty docker rm

### Delete all stopped containers

docker ps -q -f status=exited | xargs --no-run-if-empty docker rm

### To show running process in a Container

docker top {containerId/name}

### To show all images

docker images

### To delete all images

docker rmi $(docker images -q)

### Delete all dangling (unused) images

docker rmi $(docker images -q -f dangling=true)

### Remove orphaned images without tags

docker rmi $(docker images | grep "^<none>" | awk '{print $3}')

## To delete all stopped containers

docker rm $(docker ps -a -q)

# xargs with --no-run-if-empty is even better as it does cleanly handle 
# the case when there is nothing to be removed.
docker ps -q -f status=exited | xargs --no-run-if-empty docker rm

============== dockerclean.sh ==============
#!/bin/bash
# Delete all stopped containers
docker ps -q -f status=exited | xargs –no-run-if-empty docker rm
# Delete all dangling (unused) images
docker images -q -f dangling=true | xargs –no-run-if-empty docker rmi
============================================

### To show running Container

docker ps
docker ps -a ## With -a option, it shows all running and stopped Containers.

### To start/stop/restart a Container.
docker start|stop|restart {containerId/name}

e.g. docker start cloudant-developer

### How to ssh into the running docker container
docker exec -it {containerId/name} {command}

e.g. docker exec -it cloudant-developer bash
Advertisements