ich habe mit einem Dockerfile und einem Docker compose yml mir eine Entwicklungs-Umgebung erstellt.
Ich möchte mit Python/Django und einer Postgres Datenbank zusammenarbeiten. Für die Administration habe ich in den Compose noch pgadmin hinein gepackt.
nach dem ich dann
Code: Alles auswählen
docker compose up
Das einzige was nicht funktioniert, ist dass der Datenbank Name standard mäßig als "postgres" gesetzt wird.
Obwohl ich in meinem yml File den Datenbank Name aber auf cpp_base gesetzt habe.
Weiß jemand von euch, was ich falsch mache ?
hier meine beiden Files:
Dockerfile
Code: Alles auswählen
# Pull base image
FROM python:3.10.4-slim-bullseye
# Set environment variables
ENV PIP_DISABLE_PIP_VERSION_CHECK 1
ENV PYTHONDONTWRITEBYTECODE 1
ENV PYTHONUNBUFFERED 1
# Set work directory
WORKDIR /docker_postgres_pgadmin
# Install dependencies
COPY ./requirements.txt .
RUN pip install -r requirements.txt
# Copy project
COPY . .
Code: Alles auswählen
version: "3.9"
services:
web:
build: .
container_name: python_django
command: python /docker_postgres_pgadmin/manage.py runserver 0.0.0.0:8000
volumes:
- .:/docker_postgres_pgadmin
ports:
- 8000:8000
depends_on:
- db
db:
image: postgres:14.5
container_name: postgres_14.5
restart: always
volumes:
- postgres_data:/var/lib/postgresql/data/
environment:
- POSTGRES_USER=postgres
- POSTGRES_PASSWORD=postgres
- POSTGRES_DB=cpp_base
ports:
- "5432:5432"
pgadmin:
container_name: pgadmin4_container
image: dpage/pgadmin4
restart: always
volumes:
- pgadmin_data:/var/lib/pgadmin
environment:
PGADMIN_DEFAULT_EMAIL: admin@admin.com
PGADMIN_DEFAULT_PASSWORD: root
ports:
- "5050:80"
volumes:
postgres_data:
pgadmin_data: