Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Agent hangs on 'connecting' when deploying using local docker #3513

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
AadamZ5 opened this issue Aug 15, 2022 · 6 comments
Closed

Agent hangs on 'connecting' when deploying using local docker #3513

AadamZ5 opened this issue Aug 15, 2022 · 6 comments
Assignees

Comments

@AadamZ5
Copy link

AadamZ5 commented Aug 15, 2022

When deploying with the docker template, it seems the container can not download the required dependencies.

Container log:

+ trap waitonexit EXIT
+ mktemp -d -t coder.XXXXXX
+ BINARY_DIR=/tmp/coder.riHRwV
+ BINARY_NAME=coder
+ BINARY_URL=http://127.0.0.1:3000/bin/coder-linux-amd64
+ cd /tmp/coder.riHRwV
+ :
+ status=
+ command -v curl
+ curl -fsSL --compressed http://127.0.0.1:3000/bin/coder-linux-amd64 -o coder
curl: (7) Failed to connect to 127.0.0.1 port 3000: Connection refused
+ status=7
error: failed to download coder agent
       command returned: 7
Trying again in 30 seconds...
+ echo error: failed to download coder agent
+ echo        command returned: 7
+ echo Trying again in 30 seconds...
+ sleep 30

This repeats and it can never reach the host network. Running on linux x86_64

I can reach the host address from outside of the container (on the host itself) and the url path gives me a file to download. Seems like the container can't reach host.

> coder version
Coder v0.8.5+95f26f7 Wed Aug 10 16:30:46 UTC 2022
https://github.com/coder/coder/commit/95f26f74b6ff6be1ffe42fceb21f70219889dc99
@kylecarbs
Copy link
Member

@AadamZ5 the container is attempting to dial localhost, which can only reach inside the container.

You'll have to use the Docker host gateway to access port 3000 on your host machine from inside the container:

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

@AadamZ5
Copy link
Author

AadamZ5 commented Aug 15, 2022

@kylecarbs I agree. However, is this something I have to manually edit in a template? How come the default docker template does not connect to the Coder instance correctly?

@kylecarbs
Copy link
Member

Agreed. I'll fix this up!

@bpmct
Copy link
Member

bpmct commented Aug 15, 2022

Thanks for reporting, at one point I think Coder always identified localhost as 127.0.0.1 in the access URL, but this behavior must have changed.

@kylecarbs
Copy link
Member

coder/terraform-provider-coder#37

Once this is merged, we can fix up the template to no longer replace the host 😎

@kylecarbs kylecarbs self-assigned this Aug 18, 2022
@kylecarbs
Copy link
Member

That change wasn't sufficient, but this one will be! coder/terraform-provider-coder#40

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

No branches or pull requests

3 participants