Skip to content

Commit

Permalink
docker build: remove image by ID, not tag
Browse files Browse the repository at this point in the history
  • Loading branch information
draganm committed Nov 5, 2019
1 parent 8ecb35b commit 31bffe0
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions resource/docker/build/docker_build_resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -167,9 +167,12 @@ func resourceDelete(d *schema.ResourceData, m interface{}) error {
return errors.Wrap(err, "while creating docker client")
}

sourceHash := d.Get("source_hash").(string)
imageID := d.Get("image_id").(string)
_, _, err = dc.ImageInspectWithRaw(context.Background(), imageID)

imageID := fmt.Sprintf("sourcebuild:%s", sourceHash)
if client.IsErrNotFound(err) {
return nil
}

_, err = dc.ImageRemove(context.Background(), imageID, types.ImageRemoveOptions{
PruneChildren: true,
Expand Down

0 comments on commit 31bffe0

Please sign in to comment.