public void removeImage ( String imageId ) throws DockerException { Preconditions . checkState ( ! StringUtils . isEmpty ( imageId ) , "Image ID can't be empty" ) ; try { WebResource webResource = client . resource ( restEndpointUrl + "/images/" + imageId ) . queryParam ( "force" , "true" ) ; LOGGER . trace ( "DELETE: {}" , webResource ) ; webResource . delete ( ) ; } catch ( UniformInterfaceException exception ) { if ( exception . getResponse ( ) . getStatus ( ) == 204 ) { //no error LOGGER . trace ( "Successfully removed image " + imageId ) ; } else if ( exception . getResponse ( ) . getStatus ( ) == 404 ) { LOGGER . warn ( "{} no such image" , imageId ) ; } else if ( exception . getResponse ( ) . getStatus ( ) == 409 ) { throw new DockerException ( "Conflict" ) ; } else if ( exception . getResponse ( ) . getStatus ( ) == 500 ) { throw new DockerException ( "Server error." , exception ) ; } else { throw new DockerException ( exception ) ; } } }
Remove an image deleting any tags it might have .