I'm new to Docker, and I'm trying to dockerize my Django application. My compose file looks like the following:
docker-compose.yml
version: '3'
services:
web:
build:
context: .
dockerfile: Dockerfile
env_file:
- csgo.env
volumes:
- .:/code
ports:
- 8000:8000
depends_on:
- db
db:
image: postgres:13
restart: always
# Optional: Map the container port to a host port to be able to connect with a local db client
ports:
- 5432:5432
env_file:
- csgo.env
environment:
- POSTGRES_PASSWORD=db_password
- DB_NAME=db_name
- DB_USER=db_user
- DB_PASSWORD=db_password
- DB_HOST=localhost
volumes:
- ./db/psql-init/db.sql:/docker-entrypoint-initdb.d/db.sql
- postgres_data:/var/lib/postgresql/data/
volumes:
postgres_data:
I try to docker-compose up
but this error occurs. I wonder what could be the problem? Why it says the PORT is already in use?
Error
[+] Running 4/4
⠿ Network csgo_default Created 0.0s
⠿ Volume "csgo_postgres_data" Created 0.0s
⠿ Container csgo-db-1 Created 0.1s
⠿ Container csgo-web-1 Created 0.1s
Attaching to csgo-db-1, csgo-web-1
Error response from daemon: Ports are not available:
exposing port TCP 0.0.0.0:5432 -> 0.0.0.0:0: listen tcp 0.0.0.0:5432:
bind: address already in use