Docker – Good to know

I don’t run docker containers locally, but on a docker VM on a remote server.
Management is done through Portainer.io which adds a nice GUI to Docker and Kubernetes.
However sometimes, the CLI is still the place to be:

Useful commands:
docker run –rm -it = run/pull image
docker ps = list all active containers
docker attach = attach to container
docker exec -it /bin/bash = run a shell in container

Build Images:
docker build -t . = Build image from Dockerfile in same directory
docker run -it bash = Start

Cleanup
docker system df = show total and active images, container,…

docker container ls -s = how much space is taken by a container
docker volume inspect = get volumes meta-data
docker container rm $(docker container ls –filter “status=exited” -aq) = cleanup docker-container!
docker rmi $(docker image ls -aq) = cleanup docker images!
docker system prune = remove all unused stuff!!

How to keep docker clean

You may also like...

Leave a Reply

Your email address will not be published.

This site uses Akismet to reduce spam. Learn how your comment data is processed.