Usefull docker commands

From DevOps Notebook

Clean up overlay folder

# docker system prune -a -f

or

# docker rm -v $(sudo docker ps -a -q -f status=exited)
# docker rmi -f  $(sudo docker images -f "dangling=true" -q)
# docker volume ls -qf dangling=true | xargs -r docker volume rm


List open sockets inside a running docker container

# docker inspect -f '{{.State.Pid}}' <container_name_or_id>
# nsenter -t <container_name_or_id> -n netstat