Docker Compose Lab-Postgres authentication problem

I have done everything as told in the docker compose lecture. They did not told about using the environment variable in postgres. When i was not using the environment variable my container was stopping. So i used the environment variable and started a new container my database started working fine. But when i use this in docker-compose.yml it gives authentication error.
This is my docker file
redis:
image: redis

db:
image: postgres:9.4
environment:
POSTGRES_PASSWORD: postgres

worker:
image: worker-app
links:
- db
- redis

vote:
image: voting-app
ports:
- 5000:80
links:
- redis

result:
image: result-app
ports:
- 5001:80
links:
- db
This is the Error
db_1 | FATAL: password authentication failed for user “postgres”
db_1 | DETAIL: Connection matched pg_hba.conf line 95: “host all all all md5”
result_1 | Waiting for db

1 Like

Please, try this yaml

version: “3”
services:
redis:
image: redis

db:
image: postgres:9.4

vote:
image: voting-app
ports:
- 5000:80
links:
- redis

worker:
image: httpd
depends_on:
- redis
- db
links:
- redis
- db

result:
image: nginx
depends_on:
- db
ports:
- 5001:80
links:
- db

Hi,

The yaml file you have shared, does not show the result page for port 5001. The page shows the welcome page of nginx.
How to resolve that?

please try with the following code:

services:

  db:

    environment:

      POSTGRES_PASSWORD: mysecretpassword

    image: postgres

  wordpress:

    image: wordpress

    ports:

    - 8085:80

version: '3.0'