Skip to content

Commit afc4575

Browse files
bpmctkylecarbs
authored andcommitted
chore: remove docker host from docker-compose (#1596)
1 parent ea7c2e7 commit afc4575

File tree

3 files changed

+10
-8
lines changed

3 files changed

+10
-8
lines changed

docker-compose.yaml

+4-3
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,11 @@ services:
66
- "7080:7080"
77
environment:
88
CODER_PG_CONNECTION_URL: "postgresql://${POSTGRES_USER:-username}:${POSTGRES_PASSWORD:-password}@database/${POSTGRES_DB:-coder}?sslmode=disable"
9+
# You'll need to set CODER_ACCESS_URL to an IP or domain
10+
# that workspaces can reach. This cannot be localhost
11+
# or 127.0.0.1 for non-Docker templates!
912
CODER_ADDRESS: "0.0.0.0:7080"
10-
# You'll need to set CODER_ACCESS_URL to an
11-
# externally-reachable IP to use non-Docker examples!
12-
CODER_ACCESS_URL: "${CODER_ACCESS_URL:-http://host.docker.internal:7080}"
13+
CODER_ACCESS_URL: "${CODER_ACCESS_URL}"
1314
volumes:
1415
- /var/run/docker.sock:/var/run/docker.sock
1516
depends_on:

examples/docker-image-builds/main.tf

+3-2
Original file line numberDiff line numberDiff line change
@@ -94,8 +94,9 @@ resource "docker_container" "workspace" {
9494
# Hostname makes the shell more user friendly: coder@my-workspace:~$
9595
hostname = lower(data.coder_workspace.me.name)
9696
dns = ["1.1.1.1"]
97-
command = ["sh", "-c", coder_agent.dev.init_script]
98-
env = ["CODER_AGENT_TOKEN=${coder_agent.dev.token}"]
97+
# Use the docker gateway if the access URL is 127.0.0.1
98+
command = ["sh", "-c", replace(coder_agent.dev.init_script, "127.0.0.1", "host.docker.internal")]
99+
env = ["CODER_AGENT_TOKEN=${coder_agent.dev.token}"]
99100
host {
100101
host = "host.docker.internal"
101102
ip = "host-gateway"

examples/docker/main.tf

+3-3
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,6 @@ variable "step2_arch" {
4747
provider "docker" {
4848
host = "unix:///var/run/docker.sock"
4949
}
50-
5150
provider "coder" {
5251
}
5352

@@ -82,8 +81,9 @@ resource "docker_container" "workspace" {
8281
# Hostname makes the shell more user friendly: coder@my-workspace:~$
8382
hostname = lower(data.coder_workspace.me.name)
8483
dns = ["1.1.1.1"]
85-
command = ["sh", "-c", coder_agent.dev.init_script]
86-
env = ["CODER_AGENT_TOKEN=${coder_agent.dev.token}"]
84+
# Use the docker gateway if the access URL is 127.0.0.1
85+
command = ["sh", "-c", replace(coder_agent.dev.init_script, "127.0.0.1", "host.docker.internal")]
86+
env = ["CODER_AGENT_TOKEN=${coder_agent.dev.token}"]
8787
host {
8888
host = "host.docker.internal"
8989
ip = "host-gateway"

0 commit comments

Comments
 (0)