Repository navigation
Description
This could either be seen as a bug, documentation improvement or both.
OS Information
- OS: Ubuntu 20.04.4 LTS running on Coder v1
coder --version:v0.5.4-devel+ad8d9dd
Steps to Reproduce
Note that here we are running coder in production mode.
- Set up postgres database
- Run coder server:
CODER_PG_CONNECTION_URL="postgres://..." coder server - Run
coder login http://127.0.0.1:3000 - Create template from docker-local example:
coder templates create docker-local -d ~/src/coder/examples/docker-local - Create workspace:
coder create -t docker-local my-test
Expected
The coder create and coder ssh my-test commands should just work™️.
Actual
(Note: I originally created this issue due to silent failure of coder create making it seem like it's just taking a long time for the workspace to start up, but that seems to be related to #1036 and possibly fixed?)
Running coder create --template=docker-local my-test gives an error:
This template has customizable parameters. Values can be
changed after create, but may have unintended side effects
(like data loss).
var.docker_image
What docker image would you like to use for your workspace?
> codercom/enterprise-base:ubuntu
┌─────────────────────────────────────────────────────────────┐
│ Workspace Preview │
├─────────────────────────────────────────────────────────────┤
│ RESOURCE STATUS ACCESS │
├─────────────────────────────────────────────────────────────┤
│ docker_container.workspace ephemeral │
│ └─ dev (linux, amd64) coder ssh my-test │
├─────────────────────────────────────────────────────────────┤
│ docker_volume.coder_volume persistent │
└─────────────────────────────────────────────────────────────┘
> Confirm create? (yes/no)
✔ Queued [45ms]
✔ Setting up [6ms]
⧗ Starting workspace
Terraform 1.1.9
coder_agent.dev: Plan to create
docker_volume.coder_volume: Plan to create
docker_container.workspace[0]: Plan to create
Plan: 3 to add, 0 to change, 0 to destroy.
coder_agent.dev: Creating...
coder_agent.dev: Creation complete after 0s [id=990e17cb-62a9-4227-9d7b-247b669321ac]
docker_volume.coder_volume: Creating...
docker_volume.coder_volume: Creation complete after 0s [id=coder-coder-my-test-root]
docker_container.workspace[0]: Creating...
docker_container.workspace[0]: Creation errored after 1s
Error: container exited immediately
✘ Starting workspace [2014ms]
exit status 1
But there is no indication as to what's wrong. With an older version of coder server (with the silent failure mentioned above), the docker container is not cleaned up and we can inspect it's log:
❯ docker logs coder-coder-my-test-root
curl: (7) Failed to connect to 127.0.0.1 port 3000: Connection refused
We see that the container didn't successfully complete its bootstap due to inability to download the agent (from a bad access URL).
There are four three things to observe here:
- The access URL is unspecified and defaulting to
127.0.0.1which is likely not what we want to propagate inside the workspace being created inside the Docker container - The coder server is not listening on the Docker interface (
--address 0.0.0.0:3000would help) - If this was a
--devinstance we might not run into this issue when a tunnel is created Thecurlerror (and subsequent container exit) did not propagate and result incoder serverbeing able to inform the user that the bootstrap failed (terraform issue? fixed as per observations in Final output on workspace creation shows "connecting" forever - confusing UX #1036?)
Notes
There are a few ways we could improve upon this, some ideas:
- Improve documentation for
examples/docker-localto mention all knobs that need to be tuned - Detect server/template configuration mismatches that can never work (e.g. the
127.0.0.1access URL is not likely to work inside any sort of container system, nor iscoder serverlistening on127.0.0.1) - Better error reporting in the cli (could we show the container error log?)
Activity
bpmct commentedon May 9, 2022
somewhat related: #1198
bpmct commentedon May 12, 2022
I'm running into this now with the docker-compose example. Idea 2 seems like a good idea since, for all intents and purposes, Coder should not run on localhost. All of the examples would fail as the servers would just dial themselves.
re. getting started UX
#1176 would be an ideal solution to get started without a domain but I understand the concern addressed in the issue.
tjcran commentedon May 16, 2022
At minimum we should have documentation that addresses this for the launch.
johnstcn commentedon May 17, 2022
#1507 should hopefully reduce the friction here.
misskniss commentedon May 17, 2022
@mafredri would you mind verifying this? @johnstcn will work on the documentation.
johnstcn commentedon May 18, 2022
@misskniss I think @bpmct may have already covered documentation in #1526
deansheather commentedon May 19, 2022
I think a good solution would be to have a "custom access URL" variable on the docker example where users could override the access URL to not use the coder default. Then we could recommend http://host.docker.internal:3000 or something in the variable description and make sure we listen on more interfaces
mafredri commentedon May 19, 2022
@deansheather I kind of like that idea but I think there'd be an advantage to it being defined in the template/server, I don't really see a use-case for the user (of
coder create) to try and figure out the coder server URL. I think we should consider (or plan for) that this could be used as a production-ready tool, not just a quick way for one person to try it out, that way the example gives an idea of what the ideal coder experience is.tjcran commentedon May 19, 2022
@deansheather is #1176 relevant to your suggestion?
bpmct commentedon May 19, 2022
I think defining this in the docker-compose is OK. They will have to override the access URL variable in docker-compose to use non-Docker examples anyways.
An error such as #1528 can help identify issues like this before it hangs on
connecting.bpmct commentedon May 23, 2022
Closed via #1596, which includes a fix to use the Docker host socket if the access URL is not set.