Terraforms docker_image extra_hosts flag get ignored

Hello, I need to add some local records into /etc/hosts of every container made from my template, so i read the docker_image documentation on terraform and teried to use the extra_hosts parameter: https://registry.terraform.io/providers/kreuzwerker/docker/latest/docs/resources/image#extra_hosts Unfortunately, it is ignored by Coder the DNS record is not resolvable in containers and the change is not save into /ets/hosts even on newly created workspaces. I added it like this: resource "docker_image" "main" { name = "coder-${data.coder_workspace.me.id}" build { context = "./build" build_args = { USER = local.username } extra_hosts=["plesk.domain.tld:192.168.3.18","plesk:192.168.3.18"] } triggers = { dir_sha1 = sha1(join("", [for f in fileset(path.module, "build/*") : filesha1(f)])) } } Any idea why this is ignored?
5 Replies
Codercord
Codercord9mo ago
<#1221947240764014763>
Category
Bug report
Product
Coder OSS (v2)
Platform
Linux
Logs
Please post any relevant logs/error messages.
Cian
Cian9mo ago
I notice that we add host.docker.internal in docker_container.workspace in the example template. I wonder if that may be overriding what you do in the docker_image above. Does adding plesk.domain.tld:192.168.3.18 as a host specification in the docker_container work? https://registry.terraform.io/providers/kreuzwerker/docker/latest/docs/resources/container#nested-schema-for-host
Šimon DJ Čecháček
Hi there, can you help me with an example? Should I add a second hosts into the it? host { host = "host.docker.internal" ip = "host-gateway" } host { host = "plesk.domain.tld" ip = "192.168.3.18" }
Cian
Cian8mo ago
I believe that's the correct syntax, yes
Šimon DJ Čecháček
Okay, that works. Thank you!
Want results from more Discord servers?
Add your server