Skip to content

Instantly share code, notes, and snippets.

@NeoHBz
Created August 18, 2024 21:50
Show Gist options
  • Select an option

  • Save NeoHBz/deb172d1b913c4cd5f9e4901c92282b1 to your computer and use it in GitHub Desktop.

Select an option

Save NeoHBz/deb172d1b913c4cd5f9e4901c92282b1 to your computer and use it in GitHub Desktop.
Docker - access Postgres on Host
services:
service_name:
image: image_uri
ports:
- "host_port:docker_port"
extra_hosts:
- "host.docker.internal:172.17.0.1" # obtained using $ ifconfig docker0
# network_mode: "host" # this is no longer needed
environment:
DATABASE_URL: postgresql://user:password@host.docker.internal:5432/db
DATABASE_TYPE: postgresql
# also make sure postgres configs accept connections from "*"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment