-
Notifications
You must be signed in to change notification settings - Fork 191
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 devices forces resource replacement at all times #603
Comments
@acolpan It would be appreciated if you could confirm whether downgrading Docker on the server resolved the issue in your situation. |
Hi, |
After upgrading to docker version 26.1.0, aside from the devices property I was having this issue with, I started experiencing a similar issue with another property named network_mode. However, there's a workaround to this problem. You can use a lifecycle property and ignore changes to those properties as in the following resource example I am sending you. I hope this helps. resource "docker_container" "qbittorrent" { |
Thanks. As I responded to @tloesch, there's a workaround to this issue. However, ignoring the changes to those properties is limiting so a permanent solution is preffered. |
@tloesch @acolpan @enc I have the same issue. I use this module (https://github.com/terraform-aws-modules/terraform-aws-lambda) to build and deploy lambdas docker. This module use this provider to build the docker image. The ressource "docker_image" is always rebuild even if context or Dockerfile doesn't changes. 😔 |
@IlyesDemineExtVeolia |
@tloesch Thanks for your response. I still have the issue with docker 25. I will wait for a permanent fix |
Hi, |
@enc |
Facing this issue as well. I poked around in Docker to see what might have broken this and believe this to be the culprit change (at least for replacements due to What's more is it looks like there's been further refinement to how they specify the default network_mode: moby/moby#48008. Examining this change makes it pretty clear what the new defaults are:
Where the actual strings are defined here: https://github.com/moby/moby/blob/2cfc2a57a84900db112bd911143de7aed719d739/api/types/network/network.go#L9-L20 (spoiler: "bridge" on Unix, "nat" on Windows). Here's hoping this may help inform a permanent solution! |
Sounds like a Docker bug to me, because their documentation explicitly states that the default is "bridge": https://docs.docker.com/engine/network/drivers/ Either the documentation is wrong or the implementation is wrong. I filed this bug report: docker/for-win#14417 |
Terraform v1.7.2
kreuzwerker/docker v3.0.2
To reproduce this issue:
Create the resource (i.e. terraform apply --auto-approve)
Right after the step 2, after a container resource is provisioned, please note that, at this moment, the state is not changed anywhere because it's just been provisioned, try the following command to see the state "# forces replacement" further below.
This should not happen! The "terraform plan" should come out as clean in full agreement with the current state of the docker container. Though the devices after the resource is provisioned works as expected, it does not pass the "terraform plan" state check. This probably is an issue with the kreuzwerker/docker provider where it misses the container state for the devices when it inquires the state of the container.
A sample configuration to reproduce this issue: main.tf
Please replace the PATH_TO_CONFIG_DIR and the PATH_TO_DOWNLOADS_DIR with anything that works for you.
Steps to reproduce the issue with the above configuration:
Verify that both the qbittorrent image as well as the container are successfully created, and the container is up and running
Run the following command to verify that the state of the qbittorrent container also looks all good including the devices
If you remove the devices, then the states, terraform's vs docker's, agree but the container does not work as expected due to the missing "dev/net/tun" set by the devices. If you keep the devices, then the container works as expected but the states do not agree, and the terraform wants to replace the container.
The text was updated successfully, but these errors were encountered: