Skip to content

Instantly share code, notes, and snippets.

@ataube
Last active June 3, 2017 10:43
Show Gist options
  • Save ataube/d2d8889a3652fd5eb81e504ed2c33358 to your computer and use it in GitHub Desktop.
Save ataube/d2d8889a3652fd5eb81e504ed2c33358 to your computer and use it in GitHub Desktop.

Revisions

  1. Andreas Taube revised this gist Jun 3, 2017. 1 changed file with 2 additions and 0 deletions.
    2 changes: 2 additions & 0 deletions Readme.md
    Original file line number Diff line number Diff line change
    @@ -17,6 +17,8 @@ This pattern can be applied to other (host) services as well.
    - `vi /usr/local/var/postgres/pg_hba.conf`
    - add `host all all 10.200.10.1/32 trust`

    # Usage
    `docker run --rm -it -e POSTGRES_URL=postgres://[email protected]:5432/myDB ataube/myImage`


    More infos here:
  2. Andreas Taube revised this gist Jun 3, 2017. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion Readme.md
    Original file line number Diff line number Diff line change
    @@ -14,7 +14,7 @@ This pattern can be applied to other (host) services as well.
    - add `listen_addresses = '127.0.0.1,10.200.10.1'`

    4. Trust the new ip
    - `vi /usr/local/var/postgres/pg_hba.conf
    - `vi /usr/local/var/postgres/pg_hba.conf`
    - add `host all all 10.200.10.1/32 trust`


  3. Andreas Taube created this gist Jun 3, 2017.
    24 changes: 24 additions & 0 deletions Readme.md
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,24 @@
    The following steps explain a workaround to connect from a container to a postgres server installed on the host system.
    This pattern can be applied to other (host) services as well.

    # Setup
    1. Install postgres
    - `brew install postgres`
    - `brew services start postgres` (https://github.com/Homebrew/homebrew-services)

    2. Attach a unused IP to the local lo0 interface
    `sudo ifconfig lo0 alias 10.200.10.1/24`

    3. Bind the postgres server to the new ip
    - `vi /usr/local/var/postgres/postgresql.conf`
    - add `listen_addresses = '127.0.0.1,10.200.10.1'`

    4. Trust the new ip
    - `vi /usr/local/var/postgres/pg_hba.conf
    - add `host all all 10.200.10.1/32 trust`



    More infos here:
    https://docs.docker.com/docker-for-mac/networking/#use-cases-and-workarounds