Skip to content

Instantly share code, notes, and snippets.

@imran-vz
Created May 15, 2021 12:50
Show Gist options
  • Save imran-vz/9390108e5bab479714db4866933bc517 to your computer and use it in GitHub Desktop.
Save imran-vz/9390108e5bab479714db4866933bc517 to your computer and use it in GitHub Desktop.

Docker

Images

  • Remove dangling images

    docker rmi $(docker images -f "dangling=true" -q)
  • List current images

    docker image ls
  • Remove all unused images

    docker image prune -a

Containers

  • Wipe out all
    docker rm $(docker ps -a -q)

Remove all the containers that are not running (exited)

docker rm $(docker ps -q -f status=exited) 

Delete all stopped containers, dangling images, networks, unused volumes and build cache

docker system prune -a --volumes

Tailing logs

docker logs -t --tail 1000 <container_name> 2>&1 | grep -i error
  • Running docker stats you’ll know about CPU, memory and network usages and if some container is not performing well you can always stop it
RUN apt-get install -y foo bar && \
    # use the packages downloaded
    ... &&\
    rm -rf /var/lib/apt/lists/*
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment