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

terraform docker provider can not apply docker config #657

Open
pedrohealthdev opened this issue Nov 11, 2024 · 0 comments
Open

terraform docker provider can not apply docker config #657

pedrohealthdev opened this issue Nov 11, 2024 · 0 comments

Comments

@pedrohealthdev
Copy link

Community Note

  • Please vote on this issue by adding a 👍 reaction to the original issue to help the community and maintainers prioritize this request
  • Please do not leave "+1" or "me too" comments, they generate extra noise for issue followers and do not help prioritize the request
  • If you are interested in working on this issue or have submitted a pull request, please leave a comment

Terraform (and docker Provider) Version

Terraform v1.9.8
on linux_amd64

  • provider registry.terraform.io/kreuzwerker/docker v3.0.2

Affected Resource(s)

  • docker_network.project
  • docker_container.nginx
  • docker_container.api
  • docker_container.db

Terraform Configuration Files

terraform {
    required_providers {
        docker = {
            source = "kreuzwerker/docker"
            version = "~>3.0.1"
        }
    }
}

provider "docker" {}

resource "docker_network" "project" {
    name = "project"
    check_duplicate = true
    internal = true
}

resource "docker_container" "db" {
    name = "db"
    hostname = "db"
    image = "postgres:12.0-alpine"
    env = ["POSTGRES_PASSWORD=postgres", "POSTGRES_DB=postgres"]
    healthcheck {
        test = ["pg_isready"]
        interval = "2s"
        retries = "3"
    }
    networks_advanced {
        name = "project"
    }
    wait = true
}

resource "docker_container" "api" {
    name = "api"
    hostname = "api"
    image = "pedrohealthdev/api"
    env = ["DB_URL=postgresql://postgres:postgres@db:5432/postgres"]
    networks_advanced {
        name = "project"
    }
}

resource "docker_container" "nginx" {
    name = "nginx"
    image = "nginx:1.27-alpine"
    ports {
        internal = "80"
        external = "80"
    }
    volumes {
        host_path = "/home/healthdev/Projects/deploy-test/nginx"
        container_path = "/etc/nginx/conf.d"
    }
    networks_advanced {
        name = "project"
    }
}

Debug Output

https://gist.github.com/pedrohealthdev/88a2a78b8b4e23f603bc1af941a287ed

Panic Output

https://gist.github.com/pedrohealthdev/88a2a78b8b4e23f603bc1af941a287ed

Expected Behaviour

Containers running correctly.

Actual Behaviour

Containers starts to run, but there are no ports published.

$ docker container ls
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
c4ccf26e2b4b nginx:1.27-alpine "/docker-entrypoint.…" 5 minutes ago Up 5 minutes nginx
108b5820a0d5 pedrohealthdev/api "python3 main.py" 5 minutes ago Up 5 minutes api
976d8e160518 postgres:12.0-alpine "docker-entrypoint.s…" 5 minutes ago Up 5 minutes db

Steps to Reproduce

  1. terraform init
  2. terraform apply

Important Factoids

I'm a beginner regarding Terraform, I'm creating this issue because the log message said:
"
This is always indicative of a bug within the plugin. It would be immensely
helpful if you could report the crash with the plugin's maintainers so that it
can be fixed. The output above should help diagnose the issue.
"

References

  • #0000
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant