I have a python web service and it simply replies on redis, for which I want to create a dev env using docker, it showed the build process was successful but I can't access the page on my host locally.
My dockerfile is
FROM python:3.8-slim
RUN apt-get update && apt-get install -y git python3-dev default-libmysqlclient-dev build-essential pkg-config libpq-dev
RUN mkdir -p -m 0700 ~/.ssh && ssh-keyscan github.com >> ~/.ssh/known_hosts
WORKDIR /code/mo_backend
COPY . .
RUN --mount=type=ssh pip install -r requirements.txt
# EXPOSE 8000
CMD ["python", "manage.py", "runserver"]
Compose file is
services:
mo_backend:
build:
context: .
ssh:
- default
ports:
- "8000:8000"
depends_on:
- redis
redis:
image: redis:5.0.7
ports:
- "6379:6379"
After I ran docker compose up
, it showed
service started
But when I tried to visit the 8000 port, it was empty.
I tried localhost:8000, 127.0.0.1:8000, 0.0.0.0:8000, neither of them worked
Im using WSL, tried to access the site on my windows host locally.