Last active
September 6, 2023 20:08
-
-
Save VaibhavUpreti/7444b2012a0579386efd45543905a6a9 to your computer and use it in GitHub Desktop.
Allow Docker containers to connect to postgres on host machine
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# DO NOT DISABLE! | |
# If you change this first entry you will need to make sure that the | |
# database superuser can access the database using some other method. | |
# Noninteractive access to all databases is required during automatic | |
# maintenance (custom daily cronjobs, replication, and similar tasks). | |
# | |
# Database administrative login by Unix domain socket | |
local all postgres peer | |
# TYPE DATABASE USER ADDRESS METHOD | |
# "local" is for Unix domain socket connections only | |
local all all peer | |
# IPv4 local connections: | |
host all all 127.0.0.1/32 scram-sha-256 | |
host all all 172.17.0.0/16 scram-sha-256 | |
#host all all 172.17.0.1:* scram-sha-2565 | |
# IPv6 local connections: | |
host all all ::1/128 scram-sha-256 | |
# Allow replication connections from localhost, by a user with the | |
# replication privilege. | |
host circuitverse_production postgres 172.31.20.172/32 scram-sha-256 | |
local replication all peer | |
host replication all 127.0.0.1/32 scram-sha-256 | |
host replication all ::1/128 scram-sha-256 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Beginner Friendly Guide to Setup - kamal on EC2
Allow redis to listen on default port for docker subnet. 172.17.0.1
ip addr
to see docker default addr.sudo vim /etc/redis/redis.conf
sudo service redis-server restart # test redis-cli -h 172.17.0.1
Initial Postgres Change
sudo -u postgres psql
Edit Postgres config
a.
sudo vim /etc/postgresql/15/main/postgresql.conf
sudo vim /etc/postgresql/*/main/pg_hba.conf
b.
prefer option1
option1:
option2:
Do
ip -h -c a
Grab the IP of eth0 -
172.31.28.209
and for docker it is172.17.0.1/16
sudo service postgresql restart # Test psql -h 172.17.0.1 -U postgres -d circuitverse_production
https://docs.newrelic.com/docs/infrastructure/install-infrastructure-agent/linux-installation/install-infrastructure-monitoring-agent-linux/