# Connect to postgres regional read replicas from docker image instances outside PRIMARY\_REGION?

**URL:** <https://community.fly.io/t/connect-to-postgres-regional-read-replicas-from-docker-image-instances-outside-primary-region/7539>\
**Category:** Questions / Help\
**Tags:** postgres\
**Created:** [September 29, 2022, 5:49pm UTC](https://community.fly.io/t/connect-to-postgres-regional-read-replicas-from-docker-image-instances-outside-primary-region/7539 "2022-09-29T17:49:13Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![wto](https://avatars.discourse-cdn.com/v4/letter/w/c67d28/32.png) [@wto](https://community.fly.io/u/wto)\
**Post date:** [September 29, 2022, 5:49pm UTC](https://community.fly.io/t/connect-to-postgres-regional-read-replicas-from-docker-image-instances-outside-primary-region/7539/1 "2022-09-29T17:49:13Z")

</div>

I understand it’s necessary to use port `5433` instead of port `5432` to connect to the nearest postgres read replica, and the conditional logic for an app is explained here

> **[High Availability & Global Replication](https://fly.io/docs/postgres/advanced-guides/high-availability-and-global-replication/)**
>
> Documentation and guides from the team at Fly.io.

I’m wondering if there are any recommended approaches for achieving this with Docker image deployments? For instance, I’ve got [hasura](https://hub.docker.com/r/hasura/graphql-engine) deployed in multiple regions and right now they all point to the primary postgres region via an ENV var.

I figured one approach might be to make a local Dockerfile that extends the image, providing a conditional ENV var to use port `5433` if `PRIMARY_REGION != CURRENT_REGION`?
