Giter VIP home page Giter VIP logo

Comments (7)

mavogel avatar mavogel commented on August 18, 2024 2

@efpe when I'm done with the swarm approach, I'll take a look at the other issues. No ETA atm

from terraform-provider-docker.

efpe avatar efpe commented on August 18, 2024

This is still happening with version v0.10.8.
Workaround is to run a local-exec script from the resource:

resource "docker_container" "asd" {
[...]
  networks = [ "${docker_network.net1.id}", "othernetwork" ]
  provisioner "local-exec" {
    command = "/usr/bin/docker network disconnect ${var.default_network_name} ${docker_container.asd.name}"
  }
}

from terraform-provider-docker.

efpe avatar efpe commented on August 18, 2024

Any news on this?

from terraform-provider-docker.

efpe avatar efpe commented on August 18, 2024

@mavogel great to hear the issues is picked up :) Thanks!

from terraform-provider-docker.

mkeeler avatar mkeeler commented on August 18, 2024

Another thing I found as a work around was to put one of the networks in the "network_mode" configuration so:

networks = ["net1", "net2"]
network_mode = "net1"

This basically causes terraform to attach the container to "net1" during the creation of the container and then "attach" to the rest of the networks post-create. Doing a second "attach" when its already attached seems to be a no-op with docker.

from terraform-provider-docker.

bhuisgen avatar bhuisgen commented on August 18, 2024

Please see my fix 587988c in PR #92 to fix this provider bug.

from terraform-provider-docker.

mavogel avatar mavogel commented on August 18, 2024

as @bhuisgen denotes his commit fixes the bug 👍 It will come with the upcoming release 1.1.0 of the provider.

the config

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

resource "docker_image" "alpine" {
  name         = "alpine:latest"
  keep_locally = true
}

resource "docker_container" "alpine" {
  name     = "foo"
  image    = "${docker_image.alpine.latest}"
  command  = ["ip", "a"]
  networks = ["tf-net"]
}

and he following steps

# use the current master branch
# for mac
$ go build -o terraform-provider-docker_v1.1.0 && mv -f terraform-provider-docker_v1.1.0 ~/.terraform.d/plugins/darwin_amd64
$ docker network create tf-net
$ terraform apply

result in

"Networks": {
                "tf-net": {
                    "IPAMConfig": null,
                    "Links": null,
                    "Aliases": [
                        "f9ee6e24549b"
                    ],
                    "NetworkID": "d4d2a6aa3c7411c913bd10a0232d915f307521bdd60d4cac9653aff3f159e4cb",
                    "EndpointID": "",
                    "Gateway": "",
                    "IPAddress": "",
                    "IPPrefixLen": 0,
                    "IPv6Gateway": "",
                    "GlobalIPv6Address": "",
                    "GlobalIPv6PrefixLen": 0,
                    "MacAddress": "",
                    "DriverOpts": null
                }
            }

from terraform-provider-docker.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.