postgres in docker

Docker containers wrap a piece of software in a complete filesystem that contains everything needed to run: code, runtime, system tools, system libraries – anything that can be installed on a server. This guarantees that the software will always run the same, regardless of its environment.

Moderator: Lillian.W@AST

Post Reply
Oleksandr
Posts: 8
youtube meble na wymiar Warszawa
Joined: Mon Apr 23, 2018 5:21 pm

postgres in docker

Post 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?

Thanks.
Oleksandr
Posts: 8
Joined: Mon Apr 23, 2018 5:21 pm

Re: postgres in docker

Post by Oleksandr »

Using

Code: Select all

docker run -it --rm --network host -v pgdata:/var/lib/postgresql/data postgres
Works fine.
vitosx
Posts: 52
Joined: Sun Sep 24, 2017 11:30 pm

Re: postgres in docker

Post 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.

EDIT:
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.
Post Reply

Return to “Docker”