Reputation: 643
I just start a sample django app. And use docker to run it. My docker image like:
FROM python:3.5
ENV PYTHONUNBUFFERED 1
RUN mkdir /code
WORKDIR /code
ADD requirements.txt /code/
RUN pip install -r requirements.txt
ADD . /code/
My docker-compose.yml file:
version: '2'
services:
django:
build: .
command: python manage.py runserver 0.0.0.0:8000
volumes:
- .:/code
ports:
- "8000:8000"
When I run docker-compose up
command,it build successfully but failed in running command: python manage.py runserver 0.0.0.0:8000
,it complained python: can't open file 'manage.py': [Errno 2] No such file or directory
.
Is this a bug in docker for windows? Because I just follow the docs of docker Quickstart: Docker Compose and Django
Thank for you help!
Upvotes: 3
Views: 3406
Reputation: 28160
I think you either missed this step: docker-compose run web django-admin.py startproject composeexample .
or you're using a directory that isn't available to the Virtual Machine that is running docker.
If it works when you remove volumes: .:/code
from the Compose file, then you know the issue is the volumes.
I believe by default only the users home directory is shared with the VM, so if you create a project outside of that tree, you won't have access to the files from volumes.
Upvotes: 4