Skip to content

feat: add SUPABASE_HOSTNAME env var to override local service host#4947

Open
kanaka wants to merge 1 commit intodevelopfrom
kanaka/hostname-env-var
Open

feat: add SUPABASE_HOSTNAME env var to override local service host#4947
kanaka wants to merge 1 commit intodevelopfrom
kanaka/hostname-env-var

Conversation

@kanaka
Copy link

@kanaka kanaka commented Mar 10, 2026

Allows the CLI to work correctly when run inside a dev container with the Docker socket bind-mounted. In that context 127.0.0.1 is the container's own loopback, not the Docker host.

Set SUPABASE_HOSTNAME=host.docker.internal to reach sibling containers via Docker Desktop's host gateway without proxying the Docker socket.


AI assistance: Claude Sonnet 4.6 in Pi Agent

  • Used to find root cause, propose fix options, draft code/test/docs.
  • I ran supabase start inside the dev container, confirmed all services healthy, reviewed/edited all code changes/text.

What kind of change does this PR introduce?

Feature

What is the current behavior?

If supbase start is run from a sibling container (e.g. with /var/run/docker.sock mounted from the host), the command is unable to connect to the those containers after starting them in order to do health checks:

$ cli/supabase start
supabase_rest_mal container logs:
10/Mar/2026:16:01:56 +0000: Starting PostgREST 14.5...
10/Mar/2026:16:01:56 +0000: Admin server listening on 0.0.0.0:3001
...
Stopping containers...
failed to execute http request: Head "http://127.0.0.1:54321/rest-admin/v1/ready": dial tcp 127.0.0.1:54321: connect: connection refused
failed to execute http request: Head "http://127.0.0.1:54321/functions/v1/_internal/health": dial tcp 127.0.0.1:54321: connect: connection refused

What is the new behavior?

$ SUPABASE_HOSTNAME=host.docker.internal cli/supabase start
Starting containers...
Started supabase local development setup.
...

Allows the CLI to work correctly when run inside a dev container with
the Docker socket bind-mounted. In that context 127.0.0.1 is the
container's own loopback, not the Docker host.

Set SUPABASE_HOSTNAME=host.docker.internal to reach sibling containers
via Docker Desktop's host gateway without proxying the Docker socket.

---

AI assistance: Claude Sonnet 4.6 in Pi Agent
- Used to find root cause, propose fix options, draft code/test/docs.
- I ran supabase start inside the dev container, confirmed all services
  healthy, reviewed/edited all code changes/text.
@kanaka kanaka requested a review from a team as a code owner March 10, 2026 16:05
@coderabbitai
Copy link

coderabbitai bot commented Mar 10, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Central YAML (base), Organization UI (inherited)

Review profile: CHILL

Plan: Pro

Run ID: 880e4b38-efd0-4e22-8cc7-1f1e0b43ccd8

📥 Commits

Reviewing files that changed from the base of the PR and between 0335b24 and bbceb86.

📒 Files selected for processing (3)
  • docs/supabase/start.md
  • internal/utils/misc.go
  • internal/utils/misc_test.go

📝 Walkthrough

Summary by CodeRabbit

  • New Features

    • CLI now supports environment variable configuration for hostname resolution in containerized environments.
  • Documentation

    • Added guidance for configuring the CLI when running inside Docker containers with socket bind-mounting.
  • Tests

    • Added test coverage for hostname environment variable configuration.

Walkthrough

The changes add support for a new SUPABASE_HOSTNAME environment variable to allow users to override the hostname used when the CLI runs inside a dev container with Docker socket bind-mounted. The GetHostname function in internal/utils/misc.go is updated to check this environment variable first, and if set, returns its value; otherwise, it retains the existing logic of deriving the host from Docker.DaemonHost(). Documentation is added to advise users on setting this variable, and tests are added to verify the environment-based behavior of the GetHostname function.

Tip

Try Coding Plans. Let us write the prompt for your AI agent so you can ship faster (with fewer bugs).
Share your feedback on Discord.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@coveralls
Copy link

Pull Request Test Coverage Report for Build 22911967653

Details

  • 6 of 6 (100.0%) changed or added relevant lines in 1 file are covered.
  • 5 unchanged lines in 1 file lost coverage.
  • Overall coverage decreased (-0.005%) to 61.731%

Files with Coverage Reduction New Missed Lines %
internal/utils/git.go 5 57.14%
Totals Coverage Status
Change from base Build 22906505523: -0.005%
Covered Lines: 7725
Relevant Lines: 12514

💛 - Coveralls

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.

2 participants