Ask Your Question

How to connect to postgres db running inside a docker?

asked 2018-05-02 05:39:29 -0500

this post is marked as community wiki

This post is a wiki. Anyone with karma >75 is welcome to improve it.

My requirement is to load data from a json file to a table in postgres. Both my StreamSeta Data Collector and Postgres 9.3.6 are running inside Docker. The image for Postgres was created with below commands:

docker create -v /var/lib/postgresql/data --name postgres9.3.6-data busybox
docker run --name local-postgres9.3.6 -e POSTGRES_PASSWORD=asecurepassword -d --volumes-from postgres9.3.6-data postgres:9.3.6
docker run -it --link local-postgres9.3.6:postgres --rm postgres:9.3.6 sh -c exec psql -h "$POSTGRES_PORT_5432_TCP_ADDR" -p "$POSTGRES_PORT_5432_TCP_PORT" -U postgres

Could you please help me what to consider the destination in StreamSets and accordingly what connection string should be provided.

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted

answered 2018-05-02 10:14:34 -0500

jeff gravatar image

It looks like your container name running Postgres is local-postgres9.3.6. Therefore, if you start the Data Collector container on the same network (which is the feature that replaces --link option you are specifying), you should be able to give the URL from within SDC like local-postgres9.3.6:port (port to be determined by examining the documentation for the Postgres image you are using).

edit flag offensive delete link more
Login/Signup to Answer

Question Tools

1 follower


Asked: 2018-05-02 05:39:29 -0500

Seen: 287 times

Last updated: May 02 '18