Unable to connect to docker image of postgres
Hi, I follow a tutorial "Laravel Docker Setup" from Tenacity and I have some troubles with connecting to DB. Sorry, forum doesn't allow me to add links to my message.
I copied files from his repo, changed values in .env file, run
docker compose up --build --detach
and my index page gets this error, I have no idea how to fix it, I'm new to Docker. I have spent f few days but no luck with it.
SQLSTATE[08006] [7] connection to server at "db" (172.18.0.2), port 5432 failed: FATAL: password authentication failed for user "aurum" (Connection: pgsql, SQL: select * from "sessions" where "id" = V4jW7aUlZb7p8P3zHsdZ66OXKyRDti3mMMT6Nrpf limit 1)
Should docker create DB, user with password for me during installation of a project?
When I check "docker logs testapp" (testapp is the name of my postgres container), I see there repeating error
2025-01-02 23:43:16.488 GMT [98] FATAL: password authentication failed for user "aurum" 2025-01-02 23:43:16.488 GMT [98] DETAIL: Role "aurum" does not exist.
Here is my docker-compose.yml
services:
app:
build:
context: ./testapp
dockerfile: Dockerfile
restart: unless-stopped
networks:
- docker-network
ports:
- 9000:9000
depends_on:
- db
queue-worker:
build:
context: ./testapp
dockerfile: Dockerfile
restart: unless-stopped
networks:
- docker-network
depends_on:
- db
command: php artisan queue:work
db:
image: bitnami/postgresql:16.3.0
platform: linux/amd64
container_name: testapp
ports:
- 5432:5432
restart: always
volumes:
- db-data:/bitnami/postgresql
environment:
- POSTGRESQL_DATABASE=${POSTGRESQL_DATABASE}
- POSTGRESQL_USERNAME=${POSTGRESQL_USERNAME}
- POSTGRESQL_PASSWORD=${POSTGRESQL_PASSWORD}
networks:
- docker-network
caddy:
image: caddy:latest
ports:
- 80:80
- 443:443
volumes:
- ./testapp:/var/www/html
- ./Caddyfile:/etc/caddy/Caddyfile
networks:
- docker-network
depends_on:
- app
redis:
image: bitnami/redis:7.2
platform: linux/amd64
ports:
- 6379:6379
restart: always
volumes:
- redis-data:/bitnami/redis/data
environment:
- ALLOW_EMPTY_PASSWORD=no
- REDIS_PASSWORD=${REDIS_PASSWORD}
- REDIS_DISABLE_COMMANDS=FLUSHDB,FLUSHALL
networks:
- docker-network
volumes:
db-data:
redis-data:
networks:
docker-network:
driver: bridge
Please or to participate in this conversation.