Comments (2)
Thank you for your report.
But I can't reproduce the issue.
terraform {
required_providers {
docker = {
source = "kreuzwerker/docker"
version = "2.8.0"
}
}
}
variable "image" {
default = "alpine:3.11.6"
}
variable "discord_token" {
description = "Discord auth token"
}
provider "docker" {
}
resource "docker_container" "wbld" {
name = "wbld"
image = docker_image.wbld.latest
command = ["tail", "-f", "/dev/null"]
env = ["DISCORD_TOKEN=${var.discord_token}"]
volumes {
volume_name = "wbld_platformio"
container_path = "/root/.platformio"
}
volumes {
volume_name = "wbld_buildcache"
container_path = "/root/.buildcache"
}
}
data "docker_registry_image" "wbld" {
name = var.image
}
resource "docker_image" "wbld" {
name = data.docker_registry_image.wbld.name
pull_triggers = [data.docker_registry_image.wbld.sha256_digest]
keep_locally = true
}
$ terraform version
Terraform v0.14.2
+ provider registry.terraform.io/kreuzwerker/docker v2.8.0
$ terraform apply -auto-approve
docker_image.wbld: Creating...
docker_image.wbld: Creation complete after 1s [id=sha256:f70734b6a266dcb5f44c383274821207885b549b75c8e119404917a61335981aalpine:3.11.6]
docker_container.wbld: Creating...
docker_container.wbld: Creation complete after 1s [id=0dc5b981ca697b87e6028a293f9ecd984042c71f7980dd95a6481f7600d656cd]
Apply complete! Resources: 2 added, 0 changed, 0 destroyed.
$ terraform destroy -auto-approve
docker_container.wbld: Destroying... [id=0dc5b981ca697b87e6028a293f9ecd984042c71f7980dd95a6481f7600d656cd]
docker_container.wbld: Destruction complete after 0s
docker_image.wbld: Destroying... [id=sha256:f70734b6a266dcb5f44c383274821207885b549b75c8e119404917a61335981aalpine:3.11.6]
docker_image.wbld: Destruction complete after 0s
Destroy complete! Resources: 2 destroyed.
$ docker images alpine:3.11.6
REPOSITORY TAG IMAGE ID CREATED SIZE
alpine 3.11.6 f70734b6a266 7 months ago 5.61MB
It succeeds to run terraform destroy
and the Docker image isn't removed.
On the other hand, if keep_locally
is false, it failed to remove the Docker image, which means the provider tried to remove the Docker image as expected.
$ terraform destroy -auto-approve
docker_container.wbld: Destroying... [id=09682e5ba28f377f25b39ff3e9e99257daa5acf781434a98820e768b83601793]
docker_container.wbld: Destruction complete after 0s
docker_image.wbld: Destroying... [id=sha256:f70734b6a266dcb5f44c383274821207885b549b75c8e119404917a61335981aalpine:3.11.6]
Error: Unable to remove Docker image: Error response from daemon: conflict: unable to delete f70734b6a266 (must be forced) - image is referenced in multiple repositories
I checked the source code and it seems that the Docker image isn't removed if keep_locally
is true.
terraform-provider-docker/docker/resource_docker_image_funcs.go
Lines 113 to 121 in b8d28d6
terraform-provider-docker/docker/resource_docker_image_funcs.go
Lines 136 to 141 in b8d28d6
from terraform-provider-docker.
Thanks. I think the error may actually be elsewhere. Sorry for false alarm.
from terraform-provider-docker.
Related Issues (20)
- docker_container devices forces resource replacement at all times HOT 11
- Support for detachable containers
- Conditionally rebuild image
- feat: Add support for additional docker_image build contexts
- Flaky `Error response from daemon: Conflict, cannot remove the default link name of the container` on `terraform destroy`
- Support for VolumeOptions.Subpath in docker_container.mounts.volume_options HOT 1
- Support for Docker Cluster Volumes HOT 1
- Error during pushing image to GCP Artifact Registry, Unable to create image, image not found: unable to get digest: Got bad response from registry: 405 Method Not Allowed HOT 1
- Error when pushing ECR public registry: `unable to get digest: Got bad response from registry: 400 Bad Request` HOT 2
- Support for error message when service didn't converge
- Docker image trigger is not working
- Using a file for storing environment variables
- Support for `triggers` or `run_when_changed` or something like it on `docker_container` or a new `docker_container_ephemeral` resource
- Support `extra_hosts`, `secrets` attribute for `docker_container` resource
- Support for using Data Sources without access to a Docker Daemon HOT 1
- DOCKER_CONFIG is incompatible w/ docker CLI variable of same name
- Support for platform emulation in docker_container HOT 1
- Allow provider override for SSH HOT 1
- "One-shot tasks" via `docker_container` fail with "Error: No such container: xxx"
- kreuzwerker/docker ignores locally installed CA certificates, passing them explicitly won't help either HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from terraform-provider-docker.