Skip to content

chore: remove docker host from docker-compose - #1596

Merged
bpmct merged 3 commits into
mainfrom
bpmct/docker-vars
May 19, 2022
Merged

bpmct merged 3 commits into
mainfrom
bpmct/docker-vars

Conversation

@bpmct

@bpmct bpmct commented May 19, 2022 •

Copy link
Copy Markdown
Member

There isn't really a great solution to get docker-compose working locally:

  • ❌ use 127.0.0.1 as access URL for docker

    • containers dial themselves instead of the Coder control panel
  • ❌ use --network=host on containers in the template

    • no network isolation for workspaces. two workspaces can't have apps on :8080
  • ❌ add host.docker.internal to docker-compose:

    • wrong URL on coder server command
    Screen Shot 2022-05-19 at 12 18 48 PM
  • ❌ add host.docker.internal to the Docker templates.

  • 🤔 admin parameter for access URL in Docker templates

    • only relevant if running on localhost
  • ✅ this hack (override and replace localhost access URL in Docker start script)

@bpmct
bpmct requested a review from johnstcn May 19, 2022 17:20
Comment thread examples/docker/main.tf
Comment on lines +84 to +86
# Use the docker gateway if the access URL is 127.0.0.1
command = ["sh", "-c", replace(coder_agent.dev.init_script, "127.0.0.1", "host.docker.internal")]
env = ["CODER_AGENT_TOKEN=${coder_agent.dev.token}"]

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@kylecarbs @johnstcn This feels hacky, but seems to address all scenarios:

  • ✅ Proper access URL (https://127.0.0.1:7080) on coder server "welcome" message
  • ✅ docker-compose example just works with Docker examples
  • ✅ Non docker-compose deployments with a proper access URL remain working with the Docker example (no hardcoded values)

@bpmct
bpmct requested a review from kylecarbs May 19, 2022 19:42

@Emyrk Emyrk left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think this is too bad. 👍

command = ["sh", "-c", coder_agent.dev.init_script]
env = ["CODER_AGENT_TOKEN=${coder_agent.dev.token}"]
# Use the docker gateway if the access URL is 127.0.0.1
command = ["sh", "-c", replace(coder_agent.dev.init_script, "127.0.0.1", "host.docker.internal")]

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice!

@bpmct
bpmct enabled auto-merge (squash) May 19, 2022 20:14
@bpmct
bpmct merged commit 4afc66f into main May 19, 2022
@bpmct
bpmct deleted the bpmct/docker-vars branch May 19, 2022 20:38
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

Successfully merging this pull request may close these issues.

3 participants