I’ve been battling with this issue for the last 4 days of my life and it’s driving me crazy.
I’m trying to deploy a service that uses a postgres DB in RHEL 8. In order to do so, I’m deploying them both using docker-compose.
The problem is that from the service container I can ping the postgres container, but the service is not able to connect the DB…
I simplified the use case, and used a docker compose that uses the adminer docker image to connect any of the listed DB managers including postgres. It works great on my machine and on the test server that uses ubuntu 20, but when I try it in RHEL 8, I can’t get access to the DB either!
This are the docker and docker-compose versions:
Docker:
Client: Docker Engine - Community
Version: 19.03.13
API version: 1.40
Go version: go1.13.15
Git commit: 4484c46d9d
Built: Wed Sep 16 17:02:36 2020
OS/Arch: linux/amd64
Experimental: false
Server: Docker Engine - Community
Engine:
Version: 19.03.13
API version: 1.40 (minimum version 1.12)
Go version: go1.13.15
Git commit: 4484c46d9d
Built: Wed Sep 16 17:01:11 2020
OS/Arch: linux/amd64
Experimental: false
containerd:
Version: 1.3.7
GitCommit: 8fba4e9a7d01810a393d5d25a3621dc101981175
runc:
Version: 1.0.0-rc10
GitCommit: dc9208a3303feef5b3839f4323d9beb36df0a9dd
docker-init:
Version: 0.18.0
GitCommit: fec3683
Docker-compose
docker-compose version 1.25.5, build 8a1c60f6
docker-py version: 4.1.0
CPython version: 3.7.5
OpenSSL version: OpenSSL 1.1.0l 10 Sep 2019
The OS
Red Hat Enterprise Linux release 8.1 (Ootpa)
The actual docker-compose that I’m using is this:
version: '3.1'
services:
db:
image: postgres
restart: always
environment:
POSTGRES_PASSWORD: example
adminer:
image: adminer
restart: always
ports:
- 8080:8080
Logs for the postgres container seem to be fine when compared to the logs that I get in the other two systems:
db_1 | The files belonging to this database system will be owned by user "postgres".
db_1 | This user must also own the server process.
db_1 |
db_1 | The database cluster will be initialized with locale "en_US.utf8".
db_1 | The default database encoding has accordingly been set to "UTF8".
db_1 | The default text search configuration will be set to "english".
db_1 |
db_1 | Data page checksums are disabled.
db_1 |
db_1 | fixing permissions on existing directory /var/lib/postgresql/data ... ok
db_1 | creating subdirectories ... ok
db_1 | selecting dynamic shared memory implementation ... posix
db_1 | selecting default max_connections ... 100
db_1 | selecting default shared_buffers ... 128MB
db_1 | selecting default time zone ... Etc/UTC
db_1 | creating configuration files ... ok
db_1 | running bootstrap script ... ok
db_1 | performing post-bootstrap initialization ... ok
db_1 | syncing data to disk ... ok
db_1 |
db_1 |
db_1 | Success. You can now start the database server using:
db_1 |
db_1 | pg_ctl -D /var/lib/postgresql/data -l logfile start
db_1 |
db_1 | initdb: warning: enabling "trust" authentication for local connections
db_1 | You can change this by editing pg_hba.conf or using the option -A, or
db_1 | --auth-local and --auth-host, the next time you run initdb.
db_1 | waiting for server to start....2020-10-12 08:18:28.489 UTC [46] LOG: starting PostgreSQL 12.4 (Debian 12.4-1.pgdg100+1) on x86_64-pc-linux-gnu, compiled by gcc (Debian 8.3.0-6) 8.3.0, 64-bit
db_1 | 2020-10-12 08:18:28.499 UTC [46] LOG: listening on Unix socket "/var/run/postgresql/.s.PGSQL.5432"
db_1 | 2020-10-12 08:18:28.545 UTC [47] LOG: database system was shut down at 2020-10-12 08:18:25 UTC
db_1 | 2020-10-12 08:18:28.557 UTC [46] LOG: database system is ready to accept connections
db_1 | done
db_1 | server started
db_1 |
db_1 | /usr/local/bin/docker-entrypoint.sh: ignoring /docker-entrypoint-initdb.d/*
db_1 |
db_1 | waiting for server to shut down...2020-10-12 08:18:28.572 UTC [46] LOG: received fast shutdown request
db_1 | .2020-10-12 08:18:28.581 UTC [46] LOG: aborting any active transactions
db_1 | 2020-10-12 08:18:28.582 UTC [46] LOG: background worker "logical replication launcher" (PID 53) exited with exit code 1
db_1 | 2020-10-12 08:18:28.583 UTC [48] LOG: shutting down
db_1 | 2020-10-12 08:18:28.648 UTC [46] LOG: database system is shut down
db_1 | done
db_1 | server stopped
db_1 |
db_1 | PostgreSQL init process complete; ready for start up.
db_1 |
db_1 | 2020-10-12 08:18:28.693 UTC [1] LOG: starting PostgreSQL 12.4 (Debian 12.4-1.pgdg100+1) on x86_64-pc-linux-gnu, compiled by gcc (Debian 8.3.0-6) 8.3.0, 64-bit
db_1 | 2020-10-12 08:18:28.694 UTC [1] LOG: listening on IPv4 address "0.0.0.0", port 5432
db_1 | 2020-10-12 08:18:28.694 UTC [1] LOG: listening on IPv6 address "::", port 5432
db_1 | 2020-10-12 08:18:28.712 UTC [1] LOG: listening on Unix socket "/var/run/postgresql/.s.PGSQL.5432"
db_1 | 2020-10-12 08:18:28.751 UTC [55] LOG: database system was shut down at 2020-10-12 08:18:28 UTC
db_1 | 2020-10-12 08:18:28.764 UTC [1] LOG: database system is ready to accept connections
Did anybody encountered this problem before? Do you have nay suggestions that I could try?
EDIT:
The adminer container logs are all the same as with the other machines. They just throw this error when trying to connect, instead an ok message:
Is the server running on host "postgres" (10.10.10.2) and accepting TCP/IP connections on port 5432?
2
Answers
Check the logs from the adminer container while in your RHEL 8 environment, you will be able to spot the issue from there.
The command will be docker logs adminer-container-name
I’m guessing you installed docker from some site. For RHEL 8, try using Podman and Buildah – OCI compatible alternatives that don’t require a daemon. This article explains it. These are the default container tools in RHEL 8.