Page 1 of 1

postgres in docker

PostPosted: Thu May 10, 2018 9:33 pm
by Oleksandr
Hello everyone.
Did anybody run Postgres docker container successfully?

I run the following commands:
Code: Select all
docker volume create pgdata
docker run -it -p 5432:5432 --rm -v pgdata:/var/lib/postgresql/data postgres

The server starts but I am not able to establish connection through mapped port.
These commands works fine on fresh Debian system.

Is there anything else to configure?


Re: postgres in docker

PostPosted: Fri May 11, 2018 4:23 am
by Oleksandr
Code: Select all
docker run -it --rm --network host -v pgdata:/var/lib/postgresql/data postgres

Works fine.

Re: postgres in docker

PostPosted: Wed May 16, 2018 6:44 pm
by vitosx
I can confirm that --publish (-p) option indeed does not work as expected, with other containers as well. I can only connect to the port from NAS itself, not from other hosts. All necessary iptables rules seem to be there... but are not working.

Actually, not all necessary iptables rules are present. There are no proper entries in FORWARD chain.
I added them with these commands, and my published port is accessible from other hosts:
Code: Select all
/volume0/usr/builtin/sbin/iptables -A FORWARD -i eth0 -o docker0 -j DOCKER
/volume0/usr/builtin/sbin/iptables -A FORWARD -i docker0 -o eth0 -j ACCEPT

Note that this configuration will most probably allow all incoming connections to docker containers, regardless of your firewall / ADM Defender settings.