I'm trying to dockerize my djangp app with postgres db and I'm having trouble, when run docker-compose, error is:
failed to solve: rpc error: code = Unknown desc = failed to solve with frontend dockerfile.v0: failed to read dockerfile: open /var/lib/docker/tmp/buildkit-mount4260694681/Dockerfile: no such file or directory Project structure in screenshot:
Dockerfile:
FROM python:3
ENV PYTHONUNBUFFERED=1
WORKDIR /app
COPY requirements.txt ./
RUN pip install -r requirements.txt
COPY . .
docker-compose:
version: "3.9"
services:
gunter:
restart: always
build: .
container_name: gunter
ports:
- "8000:8000"
command: python manage.py runserver 0.0.0.0:8080
depends_on:
- db
db:
image: postgres
Then: docker-compose run gunter
What am I doing wrong?
I tried to change directories, but everything seems to be correct, I tried to change the location of the Dockerfile
CodePudding user response:
In your docker-compose.yml
, you are trying to make a build from your app, from .
. But the Dockerfile
is not there, so docker-compose wouldn't be able to build anything.
You can pass the path of you Dockerfile
:
version: "3.9"
services:
gunter:
restart: always
build: ./gunter_site/
container_name: gunter
ports:
- "8000:8000"
command: python manage.py runserver 0.0.0.0:8080
depends_on:
- db
db:
image: postgres