GithubHelp home page GithubHelp logo

realpython / dockerizing-django Goto Github PK

View Code? Open in Web Editor NEW
1.3K 42.0 487.0 23 KB

Home Page: https://realpython.com/blog/python/django-development-with-docker-compose-and-machine/

Python 78.27% HTML 17.71% CSS 0.70% Dockerfile 3.32%

dockerizing-django's Introduction

Django Development With Docker Compose and Machine

Featuring:

  • Docker v18.09.2
  • Docker Compose v1.23.2
  • Docker Machine v0.16.1
  • Python 3.7.3

Blog post -> https://realpython.com/blog/python/django-development-with-docker-compose-and-machine/

OS X Instructions

  1. Start new machine - docker-machine create -d virtualbox dev;
  2. Configure your shell to use the new machine environment - eval $(docker-machine env dev)
  3. Build images - docker-compose build
  4. Start services - docker-compose up -d
  5. Create migrations - docker-compose run web /usr/local/bin/python manage.py migrate
  6. Grab IP - docker-machine ip dev - and view in your browser

dockerizing-django's People

Contributors

dahlitzflorian avatar dansondergaard avatar dbader avatar feroda avatar jamlen avatar lisitsky avatar lukeorland avatar mjhea0 avatar rchamarthi avatar slykar avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

dockerizing-django's Issues

Not changing code before run unit tests

When I create and run the container, I run the tests to check the result. But when I make a change, it is not reflected and shows the same result. How can he see this change in code?

SessionAuthentiationMiddleware error

Hi,

When I try to start docker up, gunicorn conainer always fails. Upon looking at the logs, I foudn that it has this :

ImportError: Module "django.contrib.auth.middleware" does not define a "SessionAuthenticationMiddleware" attribute/class

I am using Django 2.2

data container pattern obsolete

docker now no longer cleans up volumes that aren't referenced so the docker data container pattern is obsolete.

https://docs.docker.com/engine/userguide/containers/dockervolumes/

Data volumes persist even if the container itself is deleted.

So you can remove the data entry in compose and replace the postgres entry with:

postgres:
  restart: always
  image: postgres:latest
  ports:
    - "5432:5432"
  volumes:
    - pgdata:/var/lib/postgresql/data/

This uses a named volume (so you can find it easily).

Should probably give redis a volume to so it's persisted:

redis:
  restart: always
  image: redis:latest
  ports:
    - "6379:6379"
  volumes:
    - redisdata:/data

App reload when code changed

Hey,

dunno if im doing something wrong, but for me priority n1 is to automatically reload app when there is code change, whether its in template or py code.

Could you help me with that?

Programming Error relation "todo_item" does not exist

I did all the steps as described in https://realpython.com/django-development-with-docker-compose-and-machine/ and after running docker-compose run web /usr/local/bin/python manage.py migrate and going to 192.168.99.100 on my browser,

ProgrammingError at /

relation "todo_item" does not exist
LINE 1: ...todo_item"."text", "todo_item"."date_posted" FROM "todo_item.

docker-compose logs gives me the following

postgres_1 | 2019-06-23 19:44:45.120 UTC [36] STATEMENT: SELECT "todo_item"."id", "todo_item"."text", "todo_item"."date_posted" FROM "todo_item" LIMIT 21

Any idea where I might have gone wrong?

Web address error - didn't send any data

Followed the steps without any error, but when I run docker-machine ip dev and access that URL in my browser, I get an error page saying the website didn't send any data. Is there a port? A proxy maybe? Something I would be running locally that would conflict?

Absolute URLs without port

So I used this to build a dockerized API with Django Rest Framework. Since I develop several projects at once, I use a different port for local development. Turns out that Django or at least Django Rest Framework was not able to produce the right absolute URLs in the browsable API. Instead of localhost:12345/api, I only got localhost/api.

What I tried:

Anyway, what fixed it for me was using $http_host instead of $host in the nginx config.

server {
    listen 80;
    # server_name localhost;
    charset utf-8;

    location /static {
        alias /usr/share/nginx/static;
    }

    location / {
        proxy_pass http://web:8000;
        proxy_set_header Host $http_host;  # $host is without port, $http_host works
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    }

}

My issue: lorey/socials-api#4
My configuration: https://github.com/lorey/socials-api/tree/d7f0bca4df5be9c662ede96aac6ae89d17890404

Hope this helps anyone. Let me know if someone finds a better solution or can explain this.

Problem with SSL

When trying to use:
docker-compose up --build -d

I get the following error:

ERROR: SSL error: HTTPSConnectionPool(host='192.168.99.100', port=2376): Max retries exceeded with url: /v1.25/containers/json?all=1&limit=-1&filters=%7B%22label%22%3A+%5B%22com.docker.compose.project%3Dportfoliodocker%22%2C+%22com.docker.compose.oneoff%3DFalse%22%5D%7D&trunc_cmd=0&size=0 (Caused by SSLError(SSLError(1, u'[SSL: TLSV1_ALERT_PROTOCOL_VERSION] tlsv1 alert protocol version (_ssl.c:727)'),))

I can fixed it with this:
export COMPOSE_TLS_VERSION=TLSv1_2
Here more info:
vmware/vic-product#955

I think this problem its for network of virtual box, but i dont know sure.
Im running ubuntu 18.04 with virtual box 5.9 and docker 19.03

gunicorn: no such file or directory

Hi some one have de same error first I run docker-compose build and after docker-compose up

I get this error.

ERROR: for django Cannot start service django: oci runtime error: container_linux.go:247: starting container process caused "exec: "/usr/local/bin/gunicorn": stat /usr/local/bin/gunicorn: no such file or directory"
ERROR: Encountered errors while bringing up the project.

Logging output

How do you view debug output and logs from print statements or logger.debug()?

docker-compose logs web shows gunicorn info only

"ProgrammingError at /" raised for line 17 of apps/todo/templates/_base.html file

I'm working through the tutorial you have (https://realpython.com/django-development-with-docker-compose-and-machine/) using

Mac High Sierra
docker-machine version 0.13.0, build 9ba6da9
docker-compose version 1.25.2, build 698e2846
Docker version 19.03.5, build 633a0ea

All the setup and migration ran successfully (at least from what I could tell) until I got to visiting the application home page locally (for me that was http://192.168.99.100). This resulted in the error

ProgrammingError at /
relation "todo_item" does not exist
LINE 1: ...todo_item"."text", "todo_item"."date_posted" FROM "todo_item...

pointing at this line (17) in the _base.html template file ...

<script src="//maxcdn.bootstrapcdn.com/bootstrap/3.3.4/js/bootstrap.min.js"></script>

I don't see any "TodoItem" model in the models.py file. Any ideas what's wrong?

How does django use data container

Hi Michael

First, appologize if here is not the right place to put my question.
This is a great latest repos that I can learn from. It almost have everything I want for my recent project, except from if the django container wants to access that data volume directly. In most cases, we need to store user uploaded files somewhere. I want to keep them in data volume, so that data backup will be easier.

dddd
Thank you very much for your contribution.
Have a good day.

postgres .env

Hi,
https://github.com/realpython/dockerizing-django/blob/master/.env I get an error when I change the information in the .env file.

example ;

# Add Environment Variables
SECRET_KEY=5(15ds+i2+%ik6z&!yer+ga9m=e%jcqiz_5wszg)r-z!2--b2d
DB_NAME=djangoproject
DB_USER=admin
DB_PASS=adminpass
DB_SERVICE=postgres
DB_PORT=5432

How should I do?

web_1       | django.db.utils.OperationalError: FATAL:  role "admin" does not exist
web_1       | 
postgres_1  | FATAL:  role "admin" does not exist
postgres_1  | FATAL:  role "admin" does not exist

Details error : https://hastebin.com/egidekidin.sql

docker-compose v2 one day ?

Hi,

I think we can upgrade docker-compose.yaml file into v2, it is more reliable than v1, and there is more features

/usr/src/app/static doesn't copy across from local

I can't seem to copy /static inside my project directory to /usr/src/app/static ... my css/js/img inside static are all missing.

All I seem to find is admin and rest_framework directories. Nothing else.

Not working collectstatic

I did not see the Admin styles. So I execute:

docker-compose run web /usr/local/bin/python manage.py collectstatic

But it returns:

django.core.exceptions.ImproperlyConfigured: You're using the staticfiles app without having set the STATIC_ROOT setting to a filesystem path.

initial migration for todo app should be done before run migrate

Before running:
/usr/local/bin/python manage.py migrate

it's necessary to run:
/usr/local/bin/python manage.py makemigrations todo

to make initial migrations for todo app itself. Otherwise model Item won't be created and app won't start.

And exec should be used instead of run in both cases:
docker-compose exec web /usr/local/bin/python manage.py migrate

It makes sense to add these commands to sh script and run it as an entrypoint for the web container.

Fill free to assign it to me if you want me to pr).

postgres conflict (5432: bind: address already in use)

Gentlemen,
i was following up with the article (https://realpython.com/blog/python/django-development-with-docker-compose-and-machine/), when i suddenly could not continue because of an error related to postgres image creation.
i have clones the online repository from github, using the link provided inside the article. i have followed the instructions. i could do "docker-compose build" successfully, but i couldn't do "docker-compose up -d", it is stopping on the level of postgres and giving the following error:

"ERROR: for postgres Cannot start service postgres: driver failed programming external connectivity on endpoint dockerizingdjango_postgres_1 (e52b1c5ae30c7398a7daf5254cea43b61567b52fae2da2e25fa7fd903d7bc516): Error starting userland proxy: listen tcp 0.0.0.0:5432: bind: address already in use"
"ERROR: Encountered errors while bringing up the project."

i have read a over the internet, especially in the official documentation of postgres, that it is a conflict with the ports.
so i have already postgresql installed locally on my laptop and i use usually "virtualenv" to work with django. i install psycopg2 inside the "virtualenv" and everything will work well.
now, back to this article, when i couldn't do "docker-compose up -d", i did "docker run -it postgres:latest" trying to interact with the image directly, it gave me a log hint:
[
waiting for server to start....LOG: could not bind IPv6 socket: Cannot assign requested address
HINT: Is another postmaster already running on port 5432? If not, wait a few seconds and retry.
LOG: database system was shut down at 2017-05-04 17:07:18 UTC
LOG: MultiXact member wraparound protections are now enabled
LOG: database system is ready to accept connections
LOG: autovacuum launcher started
done
server started
ALTER ROLE

/usr/local/bin/docker-entrypoint.sh: ignoring /docker-entrypoint-initdb.d/*

LOG: received fast shutdown request
LOG: aborting any active transactions
waiting for server to shut down....LOG: autovacuum launcher shutting down
LOG: shutting down
LOG: database system is shut down
done
server stopped

PostgreSQL init process complete; ready for start up.

LOG: database system was shut down at 2017-05-04 17:07:20 UTC
LOG: MultiXact member wraparound protections are now enabled
LOG: autovacuum launcher started
LOG: database system is ready to accept connections
]
Question:
is it really a matter of ports, or something else?

thank you

Bug internationalizations

$ docker-compose run web apt-get install -y gettext
Reading package lists... Done
Building dependency tree
Reading state information... Done
Package gettext is not available, but is referred to by another package.
This may mean that the package is missing, has been obsoleted, or
is only available from another source

E: Package 'gettext' has no installation candidate

It should not be included in the package? internationalizations. :)

Aren't there secure issues since we expose 6379:6379

https://github.com/realpython/dockerizing-django/blob/master/docker-compose.yml
wrote

redis:
  restart: always
  build: ./redis
  ports:
    - "6379:6379"

I think this may expose 6379 to the whole internet?
Although in production.yml changed to

ports:
  - "6379"

it expose a random port to the whole internet

And from compose file reference https://docs.docker.com/compose/compose-file/#/ports
there is a format

ports:
   - "127.0.0.1:8001:8001"

Would this be safer? Any ideas?

Can't find xgettext


$> docker-compose run web /usr/local/bin/python manage.py makemessages
CommandError: Can't find xgettext. Make sure you have GNU gettext tools 0.15 or newer installed.

Debug enabled in production

Hi,

I just noticed that, with the current setup, debug mode is enabled in production. More specifically:

https://github.com/realpython/dockerizing-django/blob/master/web/docker_django/settings.py#L26

should probably be something like DEBUG = True if os.getenv('DEBUG') == 'True' else False. I use this in my own setup and I prefer the default to be False to avoid accidentally enabling debug mode (e.g. if the setting is forgotten in .env).

I know this is only an example, but I think it's better to show people best practices :-)

volume: loop restarting web container

if use volumes: in docker-compose.yml with ./web: for local mirror, the container don't start..

  volumes:
    - ./web:/usr/src/app

someone know how make available the volumes using docker-compose?
thanks in advance,

static volume

in production you have a static volume for the statics like in dev. But how does this scale to N hosts?

Isn't this against the docker container philosophy now that you are maintaining state? If I need to put the app container on multiple hosts who controls the static? How does it get to the nginx host?

What do you think instead of putting collectstatic into the dockerfile and serving static content with whitenoise?

failed to manage.py migrate

Hi,
I'm running your example on windows10.
When I run the
docker-compose run -d web /usr/local/bin/python manage.py migrate
I get an
ERROR: Container command 'C:/Program Files/Git/usr/local/bin/python' not found or does not exist.

My workaround was to run
docker-compose run -d web python manage.py migrate

FYI

Test Workflow Django

Would it be possible to include an example of documentation on how to run unit tests when building the containers? I can submit a pull request for this, but wasn't sure if it was something you wanted in there.

Service 'nginx' failed to build: ... read-only file system

I'm on OS X El Capitan.

➜  docker docker-compose version
docker-compose version 1.6.0, build d99cad6
docker-py version: 1.7.0
CPython version: 2.7.9
OpenSSL version: OpenSSL 1.0.1j 15 Oct 2014
➜  docker docker version
Client:
 Version:      1.10.2
 API version:  1.22
 Go version:   go1.5.3
 Git commit:   c3959b1
 Built:        Mon Feb 22 22:37:33 2016
 OS/Arch:      darwin/amd64

Server:
 Version:      1.11.2
 API version:  1.23
 Go version:   go1.5.4
 Git commit:   b9f10c9
 Built:        Wed Jun  1 21:20:08 2016
 OS/Arch:      linux/amd64

Detailed log:

➜  django2 git:(master) docker-compose build
redis uses an image, skipping
postgres uses an image, skipping
Building web
Step 1 : FROM python:3.5-onbuild
3.5-onbuild: Pulling from library/python
51f5c6a04d83: Already exists
65e9ddd8bd7a: Already exists
c41545ebedf5: Already exists
04aed1875617: Already exists
cf8af6bdf113: Already exists
b1dde6937fab: Pull complete
c8bc9f75687c: Pull complete
b8e93735119c: Pull complete
Digest: sha256:64873fca593ef95e3e6ff2759f1be8850e2df13c4abc379c28d876fff80bd491
Status: Downloaded newer image for python:3.5-onbuild
# Executing 3 build triggers...
Step 1 : COPY requirements.txt /usr/src/app/
Step 1 : RUN pip install --no-cache-dir -r requirements.txt
 ---> Running in 72d7552b9c02
Collecting Django==1.8.1 (from -r requirements.txt (line 1))
  Downloading Django-1.8.1-py2.py3-none-any.whl (6.2MB)
Collecting gunicorn==19.3.0 (from -r requirements.txt (line 2))
  Downloading gunicorn-19.3.0-py2.py3-none-any.whl (110kB)
Collecting psycopg2==2.6 (from -r requirements.txt (line 3))
  Downloading psycopg2-2.6.tar.gz (367kB)
Collecting redis==2.10.3 (from -r requirements.txt (line 4))
  Downloading redis-2.10.3.tar.gz (86kB)
Installing collected packages: Django, gunicorn, psycopg2, redis
  Running setup.py install for psycopg2: started
    Running setup.py install for psycopg2: finished with status 'done'
  Running setup.py install for redis: started
    Running setup.py install for redis: finished with status 'done'
Successfully installed Django-1.8.1 gunicorn-19.3.0 psycopg2-2.6 redis-2.10.3
Step 1 : COPY . /usr/src/app
 ---> f802f2dfd11d
Removing intermediate container 5bb1297979d0
Removing intermediate container 72d7552b9c02
Removing intermediate container 95570b5a7fd9
Successfully built f802f2dfd11d
Building nginx
Step 1 : FROM tutum/nginx
latest: Pulling from tutum/nginx
faecf96fd5ab: Downloading [==================================================>] 28.36 MB/28.36 MB
995977506e98: Download complete
efb63fb8dcb6: Download complete
a3ed95caeb02: Download complete
fc9f65f1d092: Download complete
a69b26be3eeb: Download complete
292e9d346afc: Download complete
2642b1ce8f09: Download complete
ERROR: Service 'nginx' failed to build: write /mnt/sda1/var/lib/docker/tmp/GetImageBlob730892159: read-only file system

production migrate command

In your guide you have:

$ docker-compose build
$ docker-compose -f production.yml up -d
$ docker-compose run web /usr/local/bin/python manage.py migrate

But shouldn't that be?

$ docker-compose -f production.yml build
$ docker-compose -f production.yml run web python -u manage.py migrate
$ docker-compose -f production.yml up -d

Needs to specify the file each time. And migrate should run before up incase there are migrations to run.

collectstatic question

I just pulled this repo to try it out. It works great but I'm not able to collect static admin files correctly.

$ docker-compose run nginx ls /usr/src/app/static
main.css

$ docker-compose run web ls /usr/src/app/static     
main.css

$ docker-compose run web /usr/local/bin/python manage.py collectstatic --noinput
Copying '/usr/local/lib/python3.5/site-packages/django/contrib/admin/static/admin/css/login.css'
...
62 static files copied to '/usr/src/app/static'.

$ docker-compose run web ls /usr/src/app/static
main.css

I was expecting to see the static files from the collectstatic command.
Should I collect static files another way?

Django Admin CSS STILL not working

I tried it with this project, following the suggestions in #8 and the admin panel still doesn't work. Can someone please provide any suggestions?

Admin CSS and static file links are broken

Django uses css files from the contrib/auth directories for it's admin screens. Since this is not part of the mounted static file directories, admin UI is broken.

In my case, the files were in /usr/local/lib/python2.7/dist-packages/django/contrib and I copied the folder to my app'ssource to get it to work. Obviously, this is a hack. Since location of the admin css files is based on the distribution, what is the right way to dockerize this?

Web in continuous restart loop, can't connect to server

Related #19

I notice something at https://github.com/mjhea0 pointing to docker/compose#1013.

I don't have a clue what's really happening in that thread.

MacOS Sierra 10.12.2 (16C67)
ef08c89

~/work/django/dockerizing-django master
❯ docker-compose version
docker-compose version 1.9.0, build 2585387
docker-py version: 1.10.6
CPython version: 2.7.12
OpenSSL version: OpenSSL 1.0.2j  26 Sep 2016

~/work/django/dockerizing-django master
❯ docker version
Client:
 Version:      1.12.5
 API version:  1.24
 Go version:   go1.6.4
 Git commit:   7392c3b
 Built:        Fri Dec 16 06:14:34 2016
 OS/Arch:      darwin/amd64

Server:
 Version:      1.12.5
 API version:  1.24
 Go version:   go1.6.4
 Git commit:   7392c3b
 Built:        Fri Dec 16 06:14:34 2016
 OS/Arch:      linux/amd64

~/work/django/dockerizing-django master
❯ docker-machine version
docker-machine version 0.8.2, build e18a919
~/work/django/dockerizing-django master
❯ docker-compose ps
            Name                          Command                 State              Ports
---------------------------------------------------------------------------------------------------
dockerizingdjango_nginx_1      /usr/sbin/nginx                  Up           0.0.0.0:80->80/tcp
dockerizingdjango_postgres_1   /docker-entrypoint.sh postgres   Up           0.0.0.0:5432->5432/tcp
dockerizingdjango_redis_1      docker-entrypoint.sh redis ...   Up           0.0.0.0:6379->6379/tcp
dockerizingdjango_web_1        /usr/local/bin/gunicorn do ...   Up           8000/tcp
dockerizingdjango_web_run_5    /usr/local/bin/python mana ...   Restarting   8000/tcp

~/work/django/dockerizing-django master
❯ docker ps
CONTAINER ID        IMAGE                     COMMAND                  CREATED             STATUS                         PORTS                    NAMES
00bc13514884        dockerizingdjango_web     "/usr/local/bin/pytho"   6 minutes ago       Restarting (0) 2 minutes ago   8000/tcp                 dockerizingdjango_web_run_5
40a0d36fde42        dockerizingdjango_nginx   "/usr/sbin/nginx"        6 minutes ago       Up 6 minutes                   0.0.0.0:80->80/tcp       dockerizingdjango_nginx_1
b9319a22dea6        dockerizingdjango_web     "/usr/local/bin/gunic"   6 minutes ago       Up 6 minutes                   8000/tcp                 dockerizingdjango_web_1
839bf6cf11ad        redis:latest              "docker-entrypoint.sh"   6 minutes ago       Up 6 minutes                   0.0.0.0:6379->6379/tcp   dockerizingdjango_redis_1
9489589b4de4        postgres:latest           "/docker-entrypoint.s"   6 minutes ago       Up 6 minutes                   0.0.0.0:5432->5432/tcp   dockerizingdjango_postgres_1

Frustratingly, the servers for dockerizingdjango_web_run_5 keep restarting, even after docker-compose kill

~/work/django/dockerizing-django master
❯ docker-compose kill
Killing dockerizingdjango_nginx_1 ... done
Killing dockerizingdjango_web_1 ... done
Killing dockerizingdjango_redis_1 ... done
Killing dockerizingdjango_postgres_1 ... done

~/work/django/dockerizing-django master
❯ docker-compose ps
            Name                          Command                 State       Ports
-------------------------------------------------------------------------------------
dockerizingdjango_nginx_1      /usr/sbin/nginx                  Exit 137
dockerizingdjango_postgres_1   /docker-entrypoint.sh postgres   Exit 137
dockerizingdjango_redis_1      docker-entrypoint.sh redis ...   Exit 137
dockerizingdjango_web_1        /usr/local/bin/gunicorn do ...   Exit 137
dockerizingdjango_web_run_5    /usr/local/bin/python mana ...   Restarting   8000/tcp

Any hints as to why there is a restart loop and what I can do to get more debug info would be helpful. That way I can provide a bit more details.

❯ docker ps
CONTAINER ID        IMAGE                   COMMAND                  CREATED             STATUS                         PORTS               NAMES
00bc13514884        dockerizingdjango_web   "/usr/local/bin/pytho"   17 minutes ago      Restarting (1) 3 minutes ago   8000/tcp            dockerizingdjango_web_run_5

Update volume in dev with docker-machine

Would there be a way to update the project code without "rebuilding" the image while in dev? The "mount volume to project directory" would not quite work with docker-machine, correct?

standard admin page?

is there a way to get the standard admin page. I followed the blog post and everything works well, however the django admin page is wonky.
screen shot 2017-02-01 at 11 47 07 pm

data and web containers are in continues Restarting state

Can't create working example, using instructions form Readme file.

docker-compose ps

Name Command State Ports

dockerizingdjango_data_1 /docker-entrypoint.sh true Restarting 5432/tcp
dockerizingdjango_nginx_1 /usr/sbin/nginx Up 0.0.0.0:80->80/tcp
dockerizingdjango_postgres_1 /docker-entrypoint.sh postgres Up 0.0.0.0:5432->5432/tcp
dockerizingdjango_redis_1 /entrypoint.sh redis-server Up 0.0.0.0:6379->6379/tcp
dockerizingdjango_web_1 /usr/local/bin/gunicorn do ... Restarting 8000/tcp

Output of docker-compose logs is:

←[33mweb_1 | ←[0m[2016-02-22 16:59:05 +0000] [1] [INFO] Starting gunicorn 19.3.0
←[33mweb_1 | ←[0m[2016-02-22 16:59:05 +0000] [1] [INFO] Listening at: http://0.0.0.0:8000 (1)
←[33mweb_1 | ←[0m[2016-02-22 16:59:05 +0000] [1] [INFO] Using worker: sync
←[33mweb_1 | ←[0m[2016-02-22 16:59:05 +0000] [8] [INFO] Booting worker with pid: 8
←[33mweb_1 | ←[0m[2016-02-22 16:59:05 +0000] [8] [ERROR] Exception in worker process:
←[33mweb_1 | ←[0mTraceback (most recent call last):
←[33mweb_1 | ←[0m File "/usr/local/lib/python3.5/site-packages/gunicorn/arbiter.py", line 507, in spawn_worker
←[33mweb_1 | ←[0m worker.init_process()
←[33mweb_1 | ←[0m File "/usr/local/lib/python3.5/site-packages/gunicorn/workers/base.py", line 118, in init_process
←[33mweb_1 | ←[0m self.wsgi = self.app.wsgi()
←[33mweb_1 | ←[0m File "/usr/local/lib/python3.5/site-packages/gunicorn/app/base.py", line 67, in wsgi
←[33mweb_1 | ←[0m self.callable = self.load()
←[33mweb_1 | ←[0m File "/usr/local/lib/python3.5/site-packages/gunicorn/app/wsgiapp.py", line 65, in load
←[33mweb_1 | ←[0m return self.load_wsgiapp()
←[33mweb_1 | ←[0m File "/usr/local/lib/python3.5/site-packages/gunicorn/app/wsgiapp.py", line 52, in load_wsgiapp
←[33mweb_1 | ←[0m return util.import_app(self.app_uri)
←[33mweb_1 | ←[0m File "/usr/local/lib/python3.5/site-packages/gunicorn/util.py", line 355, in import_app
←[33mweb_1 | ←[0m import(module)
←[33mweb_1 | ←[0mImportError: No module named 'docker_django'
←[33mweb_1 | ←[0mTraceback (most recent call last):
←[33mweb_1 | ←[0m File "/usr/local/lib/python3.5/site-packages/gunicorn/arbiter.py", line 507, in spawn_worker
←[33mweb_1 | ←[0m worker.init_process()
←[33mweb_1 | ←[0m File "/usr/local/lib/python3.5/site-packages/gunicorn/workers/base.py", line 118, in init_process
←[33mweb_1 | ←[0m self.wsgi = self.app.wsgi()
←[33mweb_1 | ←[0m File "/usr/local/lib/python3.5/site-packages/gunicorn/app/base.py", line 67, in wsgi
←[33mweb_1 | ←[0m self.callable = self.load()
←[33mweb_1 | ←[0m File "/usr/local/lib/python3.5/site-packages/gunicorn/app/wsgiapp.py", line 65, in load
←[33mweb_1 | ←[0m return self.load_wsgiapp()
←[33mweb_1 | ←[0m File "/usr/local/lib/python3.5/site-packages/gunicorn/app/wsgiapp.py", line 52, in load_wsgiapp
←[33mweb_1 | ←[0m return util.import_app(self.app_uri)
←[33mweb_1 | ←[0m File "/usr/local/lib/python3.5/site-packages/gunicorn/util.py", line 355, in import_app
←[33mweb_1 | ←[0m import(module)
←[33mweb_1 | ←[0mImportError: No module named 'docker_django'
←[33mweb_1 | ←[0m[2016-02-22 16:59:05 +0000] [8] [INFO] Worker exiting (pid: 8)
←[33mweb_1 | ←[0mTraceback (most recent call last):
←[33mweb_1 | ←[0m File "/usr/local/bin/gunicorn", line 11, in
←[33mweb_1 | ←[0m sys.exit(run())
←[33mweb_1 | ←[0m File "/usr/local/lib/python3.5/site-packages/gunicorn/app/wsgiapp.py", line 74, in run
←[33mweb_1 | ←[0m WSGIApplication("%(prog)s [OPTIONS] [APP_MODULE]").run()
←[33mweb_1 | ←[0m File "/usr/local/lib/python3.5/site-packages/gunicorn/app/base.py", line 189, in run
←[33mweb_1 | ←[0m super(Application, self).run()
←[33mweb_1 | ←[0m File "/usr/local/lib/python3.5/site-packages/gunicorn/app/base.py", line 72, in run
←[33mweb_1 | ←[0m Arbiter(self).run()
←[33mweb_1 | ←[0m File "/usr/local/lib/python3.5/site-packages/gunicorn/arbiter.py", line 174, in run
←[33mweb_1 | ←[0m self.manage_workers()
←[33mweb_1 | ←[0m File "/usr/local/lib/python3.5/site-packages/gunicorn/arbiter.py", line 477, in manage_workers
←[33mweb_1 | ←[0m self.spawn_workers()
←[33mweb_1 | ←[0m File "/usr/local/lib/python3.5/site-packages/gunicorn/arbiter.py", line 541, in spawn_workers
←[33mweb_1 | ←[0m time.sleep(0.1 * random.random())
←[33mweb_1 | ←[0m File "/usr/local/lib/python3.5/site-packages/gunicorn/arbiter.py", line 214, in handle_chld
←[33mweb_1 | ←[0m self.reap_workers()
←[33mweb_1 | ←[0m File "/usr/local/lib/python3.5/site-packages/gunicorn/arbiter.py", line 459, in reap_workers
←[33mweb_1 | ←[0m raise HaltServer(reason, self.WORKER_BOOT_ERROR)
←[33mweb_1 | ←[0mgunicorn.errors.HaltServer: <HaltServer 'Worker failed to boot.' 3>
←[31mERROR←[0m: Aborting.

Please add a license!

Hi there,

Thank you for a great tutorial and letting us see a great code example. I always prefer to know explicitly how you would want us to use/reuse code that in which you put your own time and work. Let us know how you want us to respect and properly use your work (I know you have a bit on the tutorial page saying we can use this as a base, but more clarification would be very helpful!).

Cheers and keep up the great work!

nginx static volume

What is a purpose of /www/static volume in the compose config you are using? I do not see it is being used anywhere.

Static Assets

Any way to let Django serve the static assets if collectstatic hasn't been run yet? It's sort of a pain to run collectstatic each time you know?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.