Docker

Cleaning images and containers

Remove stopped containers and unused images:

$ docker container prune -f
$ docker image prune -f
$ docker ps/images -> docker rm/rmi

Cleaning docker registry

To completely wipe the registry to get rid of accumulated layers:

$ cat docker-compose.yml
services:
  registry:
    ...
    volumes:
    - /root/registry_data:/var/lib/registry
    ...

$ rm -rf registry_data/docker/

Do not map ports externally

When doing docker run -p 5432:5432 postgres docker modifies the iptables so that you can now connect to 5432 port from outside. To avoid this behaviour map localhost to the container port:

$ docker run -p 127.0.0.1:5432:5432 postgres