Skip to content

No longer able to accept external connections #134

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
theothermike opened this issue Mar 14, 2016 · 5 comments
Closed

No longer able to accept external connections #134

theothermike opened this issue Mar 14, 2016 · 5 comments

Comments

@theothermike
Copy link

Since commit '@yosifkit yosifkit Merge pull request #127 from infosiftr/listen_addresses' the Docker container is no longer able to accept external connections.

The patch only applies the listen_addresses='*' to the sample postgres.conf file, and since there are no instructions in docs as to how to override this, you end up with a docker container running postres, and able to connect from within the container, but not from without

this affects some downstream dockers like mdillon/postgis (will file an issue there too, in case it becomes a config option)

@yosifkit
Copy link
Member

It seems to be accessible from other containers:

$ docker pull postgres
Using default tag: latest
latest: Pulling from library/postgres
Digest: sha256:6c4dc1a323d53ab10726565dd6da34a72dd5f9f9277b45b4022455ab2469fefa
Status: Image is up to date for postgres:latest
$ docker run -d --name some-postgres postgres
$ docker run -it --rm --link some-postgres:postgres postgres sh -c 'exec psql -h "$POSTGRES_PORT_5432_TCP_ADDR" -p "$POSTGRES_PORT_5432_TCP_PORT" -U postgres'
psql (9.5.1)
Type "help" for help.

postgres=# select 1;
 ?column? 
----------
        1
(1 row)

postgres=# 

We have not yet added docs on overriding the config, 😞

If you are replacing the .example with something like -v /my/local/postgres.conf:/usr/share/postgresql/postgresql.conf.sample then you would need to make sure that your conf file has a listen_addresses='*'. (where as a previously undocumented feature, you could've mounted to /usr/share/postgresql/9.5/postgresql.conf.sample and the startup script would've rewritten your listen address line for you.)

If you have a config that doesn't have a listen address and want to get it to work, you can just add the listen address to the args:

$ docker run -d -v /.../my.config:/...sample postgres -o "-c listen_addresses='*'"

@theothermike
Copy link
Author

Apologies, you can close this issue out. We had been using 'postgis' which is based on 'postgres', and it appears that's what's causing the breakage for listen_addresses.

It turns out we dont use the features from postgis anymore, and I just tried the 9.4 version of your postgres module, and indeed, you are right, we are able to connect remotely

@omidraha
Copy link

omidraha commented Apr 2, 2016

@yosifkit

For this command, to replacing postgresql.conf.sample file:

$ docker run --rm --name ps-master  \
-v /local/postgres/postgresql.conf:/usr/share/postgresql/postgresql.conf.sample  \
postgres:9.4

There is a permission error:

creating configuration files ... initdb: 
could not open file "/usr/share/postgresql/9.4/postgresql.conf.sample" for reading: Permission denied

Because owner of /var/lib/postgresql/data/ path is set correctly to the postgres user.

But owner of /usr/share/postgresql/9.4/ path is root user currently:

root@01c449c5a060:/# ls -la  /usr/share/postgresql/9.4/
total 1000
drwxr-xr-x 7 root root   4096 Mar  9 02:34 .
drwxr-xr-x 3 root root   4096 Mar  9 02:34 ..
drwxr-xr-x 2 root root   4096 Mar  3 00:07 contrib
-rw-r--r-- 1 root root  74932 Feb 10 13:07 conversion_create.sql
drwxr-xr-x 2 root root  12288 Mar  3 00:07 extension
-rw-r--r-- 1 root root 106896 Feb 10 13:07 information_schema.sql
drwxr-xr-x 4 root root   4096 Mar  3 00:07 man
-rw-r--r-- 1 root root   4412 Feb 10 13:07 pg_hba.conf.sample
-rw-r--r-- 1 root root   1636 Feb 10 13:07 pg_ident.conf.sample
-rw-r--r-- 1 root root    640 Feb 10 13:07 pg_service.conf.sample
-rw-r--r-- 1 root root 567996 Feb 10 13:07 postgres.bki
-rw-r--r-- 1 root root 107368 Feb 10 13:07 postgres.description
lrwxrwxrwx 1 root root     25 Mar  9 02:34 postgresql.conf.sample -> ../postgresql.conf.sample
-rw-r--r-- 1 root root     49 Feb 10 13:07 postgres.shdescription
-rw-r--r-- 1 root root    278 Feb 10 13:08 psqlrc.sample
-rw-r--r-- 1 root root   5587 Feb 10 13:07 recovery.conf.sample
-rw-r--r-- 1 root root  13337 Feb 10 13:07 snowball_create.sql
-rw-r--r-- 1 root root  33072 Feb 10 13:07 sql_features.txt
-rw-r--r-- 1 root root  31130 Feb 10 13:07 system_views.sql
drwxr-xr-x 2 root root   4096 Mar  3 00:07 timezonesets
drwxr-xr-x 2 root root   4096 Mar  3 00:07 tsearch_data

@yosifkit
Copy link
Member

yosifkit commented Apr 4, 2016

@omidraha that seems like the file you are mounting in is not readable by the postgres user in the container; maybe a chmod +r on your host? The directory readability looks fine to me.

@omidraha
Copy link

omidraha commented Apr 5, 2016

@yosifkit , Fixed by chmod +r, Thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants