简体   繁体   中英

Docker for windows10 run django fail: Can't open file 'manage.py': [Errno 2] No such file or directory

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!

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM