Docker old images cleanup?

The output of sudo docker images shows images that were created ages ago, I don’t see any use for them, sudo docker system prune does not remove them either.

How can I easily delete old images? Do I have to write a script to conditionally delete based on date created within the output of docker images?

  • Matplotlib building on docker
  • appSettings.json for .NET Core app in Docker?
  • Build and run a development environment with Docker
  • ImagePullBackOff local repository with Minikube
  • Docker container sending empty responses
  • DNS not working on Docker image running in Google Compute Engine node
  • docker push fails due to “unauthorized: authentication required”, using gitlab
  • Connecting to Kubernetes master, updating heapster
  • Application takes different amount of memory on different systems
  • Gradle not able to download andriod packages
  • docker-compose issue with hadoop + hbase setup
  • How to remove port from docker container?
  • One Solution collect form web for “Docker old images cleanup?”

    I don’t think you can filter images by created date, but you can use another image as a reference of time.

    The flag (-f or--filter) with before shows only images created before the image with given id or reference.

    For example, having these images:

    $ docker images
    
    REPOSITORY          TAG                 IMAGE ID            CREATED              SIZE
    image1              latest              eeae25ada2aa        4 minutes ago        188.3 MB
    image2              latest              dea752e4e117        9 minutes ago        188.3 MB
    image3              latest              511136ea3c5a        25 minutes ago       188.3 MB
    

    Filtering with before (image1) would give:

    $ docker images --filter "before=eeae25ada2aa"
    
    REPOSITORY          TAG                 IMAGE ID            CREATED              SIZE
    image2              latest              dea752e4e117        9 minutes ago        188.3 MB
    image3              latest              511136ea3c5a        25 minutes ago       188.3 MB
    

    To Remove images before image1(eeae25ada2aa)

    $ docker rmi $(docker images --filter "since=511136ea3c5a" -q)
    
    dea752e4e117
    511136ea3c5a 
    
    Docker will be the best open platform for developers and sysadmins to build, ship, and run distributed applications.