Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Docker container -> volume deps are broken #5728

Closed
lvjp opened this issue Mar 19, 2016 · 2 comments
Closed

Docker container -> volume deps are broken #5728

lvjp opened this issue Mar 19, 2016 · 2 comments

Comments

@lvjp
Copy link
Contributor

lvjp commented Mar 19, 2016

Resource docker_volume in not in dependencies if docker_container even if it's used.

You can see my problem through this gist

@jen20
Copy link
Contributor

jen20 commented Mar 22, 2016

Hi @lvjp! I just reproduced this using the configuration in your gist. I'm using:

main.tf

provider "docker" {
    host = "unix:///var/run/docker.sock"
}

resource "docker_container" "dummy_container" {
    name = "dummy"
    image = "${docker_image.dummy_image.latest}"
    must_run = "true"
    entrypoint = [ "/bin/sleep" ]
    command = [ "365d" ]
    volumes = {
        volume_name = "${docker_volume.dummy_volume.name}"
        container_path = "/tmp/dummy"
    }
}

resource "docker_image" "dummy_image" {
    name = "busybox:latest"
}

resource "docker_volume" "dummy_volume" {
    name = "dummy-volume"
}

A terraform apply then a docker ps shows a running container:

ID        IMAGE               COMMAND             CREATED              STATUS              PORTS               NAMES
5271c09f038a        47bcc53f74dc        "/bin/sleep 365d"   About a minute ago   Up About a minute                       dummy

And using docker inspect 5271c09f038a shows the mounted volume:

...
"Mounts": [
            {
                "Name": "dummy-volume",
                "Source": "/mnt/sda1/var/lib/docker/volumes/dummy-volume/_data",
                "Destination": "/tmp/dummy",
                "Driver": "local",
                "Mode": "rw",
                "RW": true,
                "Propagation": "rprivate"
            }
        ],
...

And finally, docker volume ls shows the volume:

DRIVER              VOLUME NAME
local               dummy-volume

Running terraform taint docker_volume.dummy_volume and then terraform apply gives:

docker_image.dummy_image: Refreshing state... (ID: sha256:47bcc53f74dc94b1920f0b34f6036096526296767650f223433fe65c35f149ebbusybox:latest)
docker_volume.dummy_volume: Refreshing state... (ID: dummy-volume)
docker_container.dummy_container: Refreshing state... (ID: 85315164cd06c04324b8dda80c22c74373809d36b9cc996604dd44ffd9805667)
docker_volume.dummy_volume: Destroying...
Error applying plan:

1 error(s) occurred:

* Error deleting volume dummy-volume: volume in use and cannot be removed

Terraform does not automatically rollback in the face of errors.
Instead, your Terraform state file has been partially updated with
any resources that successfully completed. Please address the error
above and apply again to incrementally change your infrastructure.

I need to look more into the mechanics of taint here to understand the expected case. I'll come back to this shortly. Thanks for opening the issue!

@ghost
Copy link

ghost commented Apr 11, 2020

I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues.

If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@ghost ghost locked and limited conversation to collaborators Apr 11, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants