2

When I run "docker-compose up" on Windows 10 docker client, I get the following errors:

counterapp_web_1 |   File "manage.py", line 7, in <module>
counterapp_web_1 |     from app import app
counterapp_db_1 | 2018-01-26T05:09:23.517693Z 0 [Warning] InnoDB: Creating foreign key constraint system tables.
counterapp_web_1 | ImportError: No module named 'app', 

Here is my dockerfile:

FROM python:3.4.5-slim

## make a local directory
RUN mkdir /counter_app
ENV PATH=$PATH:/counter_app
ENV PYTHONPATH /counter_app

# set "counter_app" as the working directory from which CMD, RUN, ADD references
WORKDIR /counter_app

# now copy all the files in this directory to /counter_app
ADD . .

# pip install the local requirements.txt
RUN pip install -r requirements.txt

# Listen to port 5000 at runtime
EXPOSE 5000

# Define our command to be run when launching the container
CMD ["python", "manage.py", "runserver"]

There is a manage.py to call folder app, under app, there is __init__.py.

VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250

1 Answers1

2

Double-check is this error on docker run is because of your directory name:

__init__.py is imported using a directory. if you want to import it as app you should put __init__.py file in directory named app

a better option is just to rename __init__.py to app.py

So a folder named app, not counter_app.

Community
  • 1
  • 1
VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250