Skip to content

Commit 2368d56

Browse files
committed
add docker troubleshooting
1 parent ed9e1db commit 2368d56

File tree

4 files changed

+64
-4
lines changed

4 files changed

+64
-4
lines changed
281 KB
Loading

dogfood/main.tf

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ terraform {
22
required_providers {
33
coder = {
44
source = "coder/coder"
5-
version = "0.6.0"
5+
version = "0.6.3"
66
}
77
docker = {
88
source = "kreuzwerker/docker"
@@ -35,6 +35,7 @@ resource "coder_agent" "dev" {
3535
sudo service docker start
3636
if [ -f ~/personalize ]; then ~/personalize 2>&1 | tee ~/.personalize.log; fi
3737
EOF
38+
connection_timeout = 10
3839
}
3940

4041
resource "coder_app" "code-server" {
@@ -118,7 +119,7 @@ resource "docker_container" "workspace" {
118119
# CPU limits are unnecessary since Docker will load balance automatically
119120
memory = 32768
120121
runtime = "sysbox-runc"
121-
env = ["CODER_AGENT_TOKEN=${coder_agent.dev.token}"]
122+
env = ["CODER_AGENT_TOKEN=sss${coder_agent.dev.token}"]
122123
host {
123124
host = "host.docker.internal"
124125
ip = "host-gateway"

examples/templates/docker/README.md

Lines changed: 57 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,25 @@ Follow the on-screen instructions to proceed.
1313

1414
Edit the `Dockerfile` and run `coder templates push` to update workspaces.
1515

16+
## Use an existing image
17+
18+
Option 1) Modify the container spec in [main.tf](./main.tf):
19+
20+
```diff
21+
resource "docker_container" "workspace" {
22+
- image = docker_image.main.name
23+
+ image = "docker.io/codercom/enterprise-base:ubuntu"
24+
```
25+
26+
Option 2) Extend the image in your Dockerfile
27+
28+
```diff
29+
- FROM ubuntu
30+
+ FROM codercom/enterprise-base:ubuntu
31+
32+
+ RUN sudo apt-get update && sudo apt-get install vnc
33+
```
34+
1635
## code-server
1736

1837
`code-server` is installed via the `startup_script` argument in the `coder_agent`
@@ -31,4 +50,41 @@ add the following features to your Coder template:
3150
- Custom container spec
3251
- More
3352

34-
We also welcome contributions!
53+
## Troubleshooting
54+
55+
### Agent is stuck "connecting" or "disconnected"
56+
57+
This often occurs because the container cannot reach your [access URL](https://coder.com/docs/coder-oss/latest/admin/configure#access-url). The container may also be missing `curl` which is required to download the agent.
58+
59+
First, check the logs of the container:
60+
61+
```sh
62+
docker ps
63+
# CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
64+
# 4334c92f86dd coder-2a86cbef-b9bd-43b6-b3f2-27bf956016c8 "sh -c '#!/usr/bin/e…" 13 minutes ago Up 13 minutes coder-bpmct-base
65+
docker logs 4334c92f86dd
66+
# + status=6
67+
# + echo error: failed to download coder agent
68+
# + echo command returned: 6
69+
# + echo Trying again in 30 seconds...
70+
# + sleep 30
71+
# + :
72+
# + status=
73+
# + command -v curl
74+
# + curl -fsSL --compressed https://coder.example.ccom/bin/coder-linux-amd64 -o coder
75+
# curl: (6) Could not resolve host: coder.example.ccom
76+
# error: failed to download coder agent
77+
# command returned: 6
78+
```
79+
80+
> Docker templates typically work with localhost and 127.0.0.1 access URLs as it rewrites to [use the docker host](https://github.com/coder/coder/pull/4306).
81+
82+
In this case, there was a typo in the access URL, which can also be verified in the "Deployment" page. Configure Coder to [use an externally-reachable access URL](https://coder.com/docs/coder-oss/latest/admin/configure#access-url).
83+
84+
![Access URL in deployment settings](https://raw.githubusercontent.com/coder/coder/main/docs/images/admin/deployment-access-url.png)
85+
86+
If you are still running into issues, see our [generic troubleshooting instructions](https://coder.com/docs/coder-oss/latest/templates#troubleshooting-templates) or reach out [on Discord](https://discord.gg/coder).
87+
88+
## How do I persist my files?
89+
90+
With this example, all files within `/home/coder` are persisted when the workspace is started and stopped. You can combine this with a startup script to install software when the workspace starts. See [resource persistance](https://coder.com/docs/coder-oss/latest/templates/resource-persistence) for more details.

examples/templates/docker/main.tf

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ terraform {
22
required_providers {
33
coder = {
44
source = "coder/coder"
5-
version = "0.6.0"
5+
version = "0.6.3"
66
}
77
docker = {
88
source = "kreuzwerker/docker"
@@ -44,6 +44,9 @@ resource "coder_agent" "main" {
4444
GIT_AUTHOR_EMAIL = "${data.coder_workspace.me.owner_email}"
4545
GIT_COMMITTER_EMAIL = "${data.coder_workspace.me.owner_email}"
4646
}
47+
48+
connection_timeout = 10
49+
troubleshooting_url = "https://github.com/coder/coder/tree/main/examples/templates/docker#troubleshooting"
4750
}
4851

4952
resource "coder_app" "code-server" {

0 commit comments

Comments
 (0)