1

docker および docker-compose を介して runserver を実行すると、次のエラーが発生し、django に接続できません。

django_1            | 2017-01-09 08:24:44,328 - INFO - worker - Listening on channels http.request, websocket.connect, websocket.disconnect, websocket.receive
django_1            | 2017-01-09 08:24:44,329 - INFO - worker - Listening on channels http.request, websocket.connect, websocket.disconnect, websocket.receive
django_1            | 2017-01-09 08:24:44,331 - INFO - worker - Listening on channels http.request, websocket.connect, websocket.disconnect, websocket.receive
django_1            | 2017-01-09 08:24:44,331 - INFO - worker - Listening on channels http.request, websocket.connect, websocket.disconnect, websocket.receive
django_1            | Unhandled exception in thread started by <function wrapper at 0x7ff06bee5d70>
django_1            | Traceback (most recent call last):
django_1            |   File "/usr/local/lib/python2.7/site-packages/django/utils/autoreload.py", line 226, in wrapper
django_1            |     fn(*args, **kwargs)
django_1            |   File "/usr/local/lib/python2.7/site-packages/channels/management/commands/runserver.py", line 84, in inner_run
django_1            | Performing system checks...
django_1            | 
django_1            | System check identified no issues (0 silenced).
django_1            | January 09, 2017 - 08:24:44
django_1            | Django version 1.10.4, using settings 'backend.settings'
django_1            | Starting Channels development server at http://0.0.0.0:8000/
django_1            | Channel layer default (asgi_redis.core.RedisChannelLayer)
django_1            | Quit the server with CONTROL-C.
django_1            |     ws_protocols=getattr(settings, 'CHANNELS_WS_PROTOCOLS', None),
django_1            |   File "/usr/local/lib/python2.7/site-packages/daphne/server.py", line 41, in __init__
django_1            |     ''' % self.__class__.__name__)
django_1            | DeprecationWarning: 
django_1            |                 The host/port/unix_socket/file_descriptor keyword arguments to Server are deprecated.
django_1            |             

ローカルで実行すると、すべて正常に実行されます。これが私のrequirements.txtです:

Django==1.10.4 psycopg2==2.6.2 チャンネル==0.17.3 asgi-redis==1.0.0

そして、これが私のdocker-composeファイルです:

version: '2' 
  services:
    redis:
      image: redis:3.0-alpine
    postgres:
        image: postgres
    django:
        build: ../backend
        command:  python backend/manage.py runserver 0.0.0.0:8000
        volumes:
            - ../backend:/backend
        ports:
            - "8000:8000"
        depends_on:
            - postgres
            - redis
            - django-migration
    django-migration:
        build: ../backend
        command: python backend/manage.py migrate
        volumes:
          - ../backend:/backend
        depends_on:
          - postgres
    client:
        image: node
        command: bash -c "cd src && npm start"
        ports:
            - "3000:3000"

何か案は?

4

2 に答える 2

1

コンテナが相互にリンクしていません。それらをネットワークに結合してみてください。

version: '2' 
  services:
    redis:
      image: redis:3.0-alpine
      networks:
       - django-network

    postgres:
        image: postgres
        networks:
         - django-network

    django:
        build: ../backend
        command:  python backend/manage.py runserver 0.0.0.0:8000
        volumes:
            - ../backend:/backend
        ports:
            - "8000:8000"
        depends_on:
            - postgres
            - redis
            - django-migration
        networks:
         - django-network

    django-migration:
        build: ../backend
        command: python backend/manage.py migrate
        volumes:
          - ../backend:/backend
        depends_on:
          - postgres
        networks:
         - django-network

    client:
        image: node
        command: bash -c "cd src && npm start"
        ports:
            - "3000:3000"
        networks:
         - django-network

     networks:
       tele-cluster-network:
         driver: bridge
于 2017-01-09T07:46:10.727 に答える