I am running simple Docker-compose example shown here
Here is Dockerfile:
FROM python:2.7
ENV PYTHONUNBUFFERED 1
RUN mkdir /code
WORKDIR /code
ADD requirements.txt /code/
RUN pip install -r requirements.txt
ADD . /code/
Here is docker-compose.yml:
version: '2'
services:
db:
image: postgres
web:
build: .
command: python manage.py runserver 0.0.0.0:8000
volumes:
- .:/code
ports:
- "8000:8000"
depends_on:
- db
When I am trying to launch the example with docker-compose it gives me following:
alex@universe:~/projects/testcompose$ docker-compose up
testcompose_db_1 is up-to-date
Recreating testcompose_web_1
Attaching to testcompose_db_1, testcompose_web_1
web_1 | python: can't open file 'manage.py': [Errno 2] No such file or directory
db_1 | The files belonging to this da...
Probably tutorial is not up to date so if you know answer please write it here.
Right, project file structure was generated correctly.
Django always has a my-project-folder/my-site/my-site
file structure.
To make it work with docker-compose you just need to move up the following files to my-project-folder/my-site/
Dockerfile
docker-compose.yml
requirements.txt
my-project-folder/my-site/
already contains manage.py
file (if that is not the case then something is wrong)
At this point make sure that my-project-folder/
only contains
my-site/
folder and nothing else.
Once everything is setup correctly just move up to my-project-folder/my-site/my-site
execute command docker-compose up
it will build everything needed.
execute command docker-compose up
a second time and there you have it.
Dont forget to check allowed host and add '0.0.0.0' on settings.py
file if needed.
that's all.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With