I
I
IndiNoob2020-08-13 13:15:27
CentOS
IndiNoob, 2020-08-13 13:15:27

Why can't connect to postgres server in docker container?

1. Have a Windows 10 Host on it --> Virtual Box on it ---> (Vagrant + CentOS 8).
2. The network between Windows 10 and CentOS works through nat
3. Docker with containers is up on CentOS

Containers
5f350d9017271139130803.png
Containers lifted through docker-compose
Here is the config
version: "3.8"
services:

  db:
    image: postgres:12.3-alpine
    container_name: postgres
    ports:
      - "5432:5432"
    volumes:
      - "./pg_data:/var/lib/postgresql/data/pg_data"
    environment:
      POSTGRES_PASSWORD: 123
      POSTGRES_DB: movieblog
      PGDATA: /var/lib/postgresql/data/pg_data
    restart: always

  adminer:
    image: adminer
    ports:
      - "8080:8080"
    restart: always

4. On the virtual box, I forwarded the ports from the host to the guest
Ports
5f350e8f12e64322766166.png

5. Gave port 5432 Accept in INPUT iptables
iptables
5f35105e6e183151454533.png
added port to firewall-cmd
firewall
5f351087711a5100126130.png


As a result, I get to the admin panel (adminer) through port 8080, I enter data but I can’t log in
Main problem
5f352873228cb766309056.png


How to be??

Answer the question

In order to leave comments, you need to log in

4 answer(s)
I
IndiNoob, 2020-08-18
@IndiNoob

CentOS 8 switched to a new firewall subsystem - nftables, and Docker only supports iptables, then networking inside containers will not work. To fix this, enable masquerade traffic with firewalld:

firewall-cmd --zone=public --add-masquerade --permanent

Then restart the firewall so that the active rules are updated:
firewall-cmd --reload

D
Dmitry, 2020-08-13
@q2digger

why are you specifying the postgres database in adminir-e when the database is called movieblog in docker-compose ?

S
SagePtr, 2015-04-04
@SagePtr

soldering iron)

S
saltydogd, 2015-04-04
@saltydogd

Some players have this option (foobar, vl, mpc), or a hard version:
3.5mm stereo to 2 RCA male plugs + 3.5mm stereo to 2 RCA female - change white tulips to red - profit
Or a very harsh option - if you have a soldering iron, well, you understand)
About the soldering iron I’m already filming the version ... ahead of

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question