I have a postgres server on my host machine and I want to make a docker container that connects to this postgres server.
So I guess I need to expose the postgres server on a connection IP:5432 to docker. Expose 5432 on the docker and specify the correct connection information inside the docker something like:
SQLALCHEMY_DATABASE_URI = "postgresql+psycopg2://username:password@IP/db_name"
The host docker IP's are:
docker0 Link encap:Ethernet HWaddr 02:42:b3:d9:eb:e2
inet addr:172.17.0.1 Bcast:172.17.255.255 Mask:255.255.0.0
inet6 addr: fe80::42:b3ff:fed9:ebe2/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:213512 errors:0 dropped:0 overruns:0 frame:0
TX packets:351284 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:9157933 (9.1 MB) TX bytes:826914241 (826.9 MB)
docker_gwbridge Link encap:Ethernet HWaddr 02:42:5c:b9:3b:0a
inet addr:172.18.0.1 Bcast:172.18.255.255 Mask:255.255.0.0
inet6 addr: fe80::42:5cff:feb9:3b0a/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:0 errors:0 dropped:0 overruns:0 frame:0
TX packets:436 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:0 (0.0 B) TX bytes:64397 (64.3 KB)
What am I missing and how does I expose the postgres server to the relavant ports both on host side.