I'm following the configuration given at this repository. I decided to keep my docker configuration and actual code in separate repositories - I'd clone the code repo using the Dockerfile. I'm using a docker-machine (locally, using the Virtualbox driver) and docker-compose setup.
The code repo's directory structure is roughly as follows -:
docker-compose.yml file is almost the same as that of the repository I listed above, with the minor difference that I mounted
django on volume
.:/root - without which a
 System error: no file or directory error was being thrown. This was probably because
/usr/src/app does not exist before the cloning (for reference, this is the original file). The Dockerfile (for the
django service) has the following -:
FROM ubuntu:14.04 ENV DJANGO_CONFIGURATION Docker # First, we need to get git, and clone our repository # Additionally, get everything else here too, such as nodejs and npm RUN apt-get update RUN apt-get install -y ca-certificates git-core ssh nodejs npm python-pip libpq-dev python-dev RUN ln -s /usr/bin/nodejs /usr/bin/node ENV HOME /root # Add custom ssh keypair - usually Bitbucket deployment keys ADD ssh/ /root/.ssh/ # Fix permissions RUN chmod 600 /root/.ssh/* # Avoid first connection host confirmation RUN ssh-keyscan bitbucket.org > /root/.ssh/known_hosts # Clone the repo WORKDIR /usr/src/app RUN git clone email@example.com:username/defsec-exam-app.git # Install requirements WORKDIR /usr/src/app/defsec-exam-app RUN pip install -r requirements.txt RUN npm install -g bower RUN bower --allow-root install # Remember to perform migrations on your own, and also create DB when needed. # S3 Storage ... # DB Settings ... WORKDIR /usr/src/app/defsec-exam-app/defsec CMD ["gunicorn", "defsec.wsgi", "-w", "2", "-b", "0.0.0.0:8000", "--log-level", "-"]
And finally, the
nginx.conf to serve the static files is as follows -:
However, I cannot get nginx to serve the static files at all - all of them return a 404. I wondered if the linking between the
django container services (as defined in
docker-compose.yml) was incorrect, but it doesn't seem like it. I also inspected the
/etc/hosts file in the
nginx container, for linking creates hostfile entries.
172.17.0.136 151ca02e891a 127.0.0.1 localhost ::1 localhost ip6-localhost ip6-loopback fe00::0 ip6-localnet ff00::0 ip6-mcastprefix ff02::1 ip6-allnodes ff02::2 ip6-allrouters 172.17.0.134 defsecdocker_django_1 eb900ed9600c 172.17.0.135 defsecdocker_nginx_1 eec99206076a 172.17.0.134 django eb900ed9600c defsecdocker_django_1 172.17.0.134 django_1 eb900ed9600c defsecdocker_django_1 172.17.0.135 nginx eec99206076a defsecdocker_nginx_1 172.17.0.135 nginx_1 eec99206076a defsecdocker_nginx_1 172.17.0.116 defsecdocker_postgres_1 172.17.0.134 defsecdocker_django_1 172.17.0.135 defsecdocker_nginx_1.bridge 172.17.0.136 defsecdocker_nginx_run_10.bridge 172.17.0.135 defsecdocker_nginx_1 172.17.0.136 defsecdocker_nginx_run_10 172.17.0.116 defsecdocker_postgres_1.bridge 172.17.0.134 defsecdocker_django_1.bridge
I'm not sure if this is right, as there are only 3 containers but a hell lot of entries in the hosts file, some of which are duplicates. This is reproducible behaviour - I get this exact file each time I build and run the container using docker-compose. The docker-compose logs for
nginx confirm the 404s.
Any pointers would be greatly appreciated.