Documentation

    PLEASE NOTE: This document applies to latest version and not to the latest stable release v2.20

    Documentation for other releases can be found by using the version selector in the top right of any doc page.

    docker_prune

    Prune unused Docker resources (containers, images, volumes, networks, build cache).

    Attributes

    check_mode:
      support: full
    

    Parameters

    Parameter Required Type Values Description
    all   boolean   Prune all types.
    builder_cache   boolean   Prune build cache.
    containers   boolean   Prune stopped containers.
    force   boolean   Do not prompt for confirmation.
    images   boolean   Prune unused images.
    networks   boolean   Prune unused networks.
    volumes   boolean   Prune unused volumes.

    Example

    - name: Clean up Docker
      docker_prune:
        containers: true
        images: true
        volumes: true
        force: true
    
    - name: Prune all Docker resources
      docker_prune:
        all: true
    
    - name: Clean stopped containers only
      docker_prune:
        containers: true
    
    - name: Clean build cache
      docker_prune:
        builder_cache: true