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?

  • ImportError: No module named package using pip in Docker
  • 404 when pulling a private Docker repo from Hub
  • Make Docker machine very fast
  • dockerfile with windows path
  • Docker devicemapper storage space
  • Build docker image from rhel6.5 image
  • Docker recreates directories on host after reboot
  • Why use Consul with Kubernetes, Docker, Mesos?
  • How can I run a docker container on localhost over the default IP?
  • Database with starttime and endtime [closed]
  • How to update a docker swarm service with no replication with zero downtime?
  • Docker-Compose: is it possible to force IP addresses on different containers?
  • 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.