Skip to content

Docker agents are prone to failing #4305

Closed as not planned
Closed as not planned
@ammario

Description

@ammario

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    staleThis issue is like stale bread.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions