Closed as not planned
Description
By default, Docker containers are on their own network and access the host via host.docker.internal
.
The existing (and non-obvious) workaround is to replace the Access URL in the init_script
. See below:
command = [
"sh", "-c",
<<EOT
trap '[ $? -ne 0 ] && echo === Agent script exited with non-zero code. Sleeping infinitely to preserve logs... && sleep infinity' EXIT
${replace(coder_agent.main.init_script, "localhost", "host.docker.internal")}
EOT
]
This approach is brittle because it strongly couples the template with the Access URL. In this example, if the Access URL is 127.0.0.1
and not localhost
, the agent will never start.
@kylecarbs suggested we add a host
attribute the coder_provider
block that would contain the host.docker.internal
isntead.