Docker Commands

Docker Commands
Photo by Dominik Lückmann / Unsplash

bash

docker exec -it pihole /bin/bash

clean all

docker rm -f $(docker ps -qa)
docker rmi -f $(docker images -q)
docker volume rm $(docker volume ls -q)

commands

docker ps # display docker containers
docker image prune # remove unused docker images
docker stats # display CPU/memory usage of running docker containers
docker kill $(docker ps -q) # stop all docker containers
docker rm $(docker ps -a -q) # remove not running docker containers
docker system prune # general cleanup

docker volume ls -q

docker inspect -f '{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' cf406583b4cf # get ip of container

expose docker API

vi /lib/systemd/system/docker.service
Add to ExecStart=. -H tcp://0.0.0.0:2375

systemctl daemon-reload
systemctl restart docker.service
export DOCKER_HOST="tcp://0.0.0.0:2375"