VS Code does not forward ports (Dev Containers)
I'm currently trying to put my Django application into a dev container. And in itself it does work, but however, I cannot access the page in my browser. I'm using this Tutorial.
./backend/Dockerfile
FROM python:3.12
EXPOSE 8000
ENV PYTHONDONTWRITEBYTECODE=1
ENV PYTHONUNBUFFERED=1
RUN pip install uv
COPY pyproject.toml uv.lock ./
RUN uv sync && uv lock
WORKDIR /app
COPY . /app
RUN adduser -u 5678 --disabled-password --gecos "" appuser && chown -R appuser /app
USER appuser
CMD [ "uv", "run", "python", "manage.py", "runserver", "0.0.0.0:8000" ]
./docker-compose.yml
name: experiments-graphql
services:
django:
image: backend
build:
context: ./backend
dockerfile: ./Dockerfile
ports:
- 8000:8000
./.devcontainer/devcontainer.json
{
"name": "Existing Docker Compose (Extend)",
"dockerComposeFile": [
"../docker-compose.yml",
"docker-compose.yml"
],
"service": "django",
"workspaceFolder": "/workspace",
"customizations": {
"vscode": {
"settings": {},
"extensions": [
"ms-python.python",
"eamodio.gitlens",
"editorconfig.editorconfig"
]
}
}
}
./.devcontainer/docker-compose.yml
services:
django:
volumes:
- .:/workspace:cached
command: /bin/sh -c "while sleep 1000; do :; done"