Skip to content

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

Merged
avallete merged 2 commits intodevelopfrom
kanaka/hostname-env-var
Apr 30, 2026
Merged

feat: add SUPABASE_HOSTNAME env var to override local service host#4947
avallete merged 2 commits intodevelopfrom
kanaka/hostname-env-var

Conversation

@kanaka
Copy link
Copy Markdown
Contributor

@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.
...

@kanaka kanaka requested a review from a team as a code owner March 10, 2026 16:05
@coderabbitai
Copy link
Copy Markdown

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
Copy Markdown

coveralls commented Mar 10, 2026

Coverage Report for CI Build 25157971085

Warning

Build has drifted: This PR's base is out of sync with its target branch, so coverage data may include unrelated changes.
Quick fix: rebase this PR. Learn more →

Coverage decreased (-0.006%) to 63.771%

Details

  • Coverage decreased (-0.006%) from the base build.
  • Patch coverage: 6 of 6 lines across 1 file are fully covered (100%).
  • 7 coverage regressions across 2 files.

Uncovered Changes

No uncovered changes found.

Coverage Regressions

7 previously-covered lines in 2 files lost coverage.

File Lines Losing Coverage Coverage
internal/utils/git.go 5 57.14%
internal/storage/rm/rm.go 2 80.61%

Coverage Stats

Coverage Status
Relevant Lines: 15634
Covered Lines: 9970
Line Coverage: 63.77%
Coverage Strength: 7.02 hits per line

💛 - Coveralls

@kanaka kanaka force-pushed the kanaka/hostname-env-var branch from bbceb86 to b1eaa19 Compare April 27, 2026 15:47
Comment thread internal/utils/misc.go Outdated
Allows the CLI to communicate with where supabase services are
listening when it differs from where the docker engine API is listening.

The concrete use case was running the CLI inside a dev container with
the host Docker socket bind-mounted. In that context 127.0.0.1 is the
container's own loopback, not the Docker host. Set
SUPABASE_SERVICES_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 force-pushed the kanaka/hostname-env-var branch from b1eaa19 to 373a19e Compare April 29, 2026 18:05
@avallete avallete enabled auto-merge (squash) April 30, 2026 09:29
@avallete avallete merged commit cd3c3d3 into develop Apr 30, 2026
15 checks passed
@avallete avallete deleted the kanaka/hostname-env-var branch April 30, 2026 09:32
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.

3 participants