Unable to create postgres container while practising example-voting-app

Hi Team,

While creating containers through docker-compose I am facing following error in Postgres DB container.

Hereby, I am attaching my code for your reference:

[root@i-09d3865c560c2dee4 opt]# cat docker-compose.yaml 
redis:
  image: redis

db:
  image: postgres:9.4

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

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

result:
  image: result-app
  ports:
    - 5001:80
  links:
    - db

My code directory:

[root@i-09d3865c560c2dee4 opt]# ls -la | grep example-voting-app
drwxr-xr-x. 10 root    root           4096 Jun 29 16:22 example-voting-app
[root@i-09d3865c560c2dee4 opt]# 
[root@i-09d3865c560c2dee4 opt]# pwd
/opt

Error:

[root@i-09d3865c560c2dee4 opt]# docker-compose up db
Recreating opt_db_1 ... 
WARNING: Service "db" is using volume "/var/lib/postgresql/data" from the previous container. Host mapping "postgres" has no effect. Remove the existinRecreating opt_db_1 ... done
Attaching to opt_db_1
db_1      | 
db_1      | PostgreSQL Database directory appears to contain a database; Skipping initialization
db_1      | 
db_1      | LOG:  unrecognized configuration parameter "max_wal_size" in file "/var/lib/postgresql/data/postgresql.conf" line 241
db_1      | LOG:  unrecognized configuration parameter "min_wal_size" in file "/var/lib/postgresql/data/postgresql.conf" line 242
db_1      | FATAL:  configuration file "/var/lib/postgresql/data/postgresql.conf" contains errors
opt_db_1 exited with code 1
[root@i-09d3865c560c2dee4 opt]# 

Kindly, help to resolve my error asap.

Thanks in advance!

Regards,
Utkarsh

Hi @utkarshvaishnav295
Apparently, you create previously a service with the same name (DB) please remove it and try again. For Postgres, you need at least the DB_PASSWORD environment variable. Please refer to the following link (section docker compose) :

https://hub.docker.com/_/postgres

Regard