# list docker volumes
docker volume ls -f dangling=true
# rm all docker volumes
docker volume rm $(docker volume ls -qf dangling=true)
# stop all docker containers
docker stop $(docker ps -a -q)
# remove all docker containers with its volume
docker rm -v $(docker ps -a -q)
# remove all containers with status of exited
# the -q flag, only returns the numeric IDs and -f filters output based on conditions provided.
$ docker rm $(docker ps -a -q -f status=exited)
# show port(s) of the given container
docker port container_name(id)
# outputs
# 80/tcp -> 0.0.0.0:32769
# 443/tcp -> 0.0.0.0:32768
# open localhost:32769/8 in brower
# specific the port when running container
# format: local_port:container_port
# here 8888 is local port 5000 is container port
docker run -p 8888:5000 image_name
# remove all docker images
docker rmi $(docker images -q)
# list volumes of a container
docker inspect -f "{{ .Config.Volumes }}" container_id
Last active
August 24, 2016 03:08
-
-
Save naifen/a419ca13b6b381bdd78a7c36fb35bcb3 to your computer and use it in GitHub Desktop.
docker and docker-compose command cheatsheet
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment