UPDATED SHORT VERSION: if I have a docker image that fails to run (but leaves very little detail as to why), is there a way to connect to the container running the image to debug it?
(Many thanks to those who pointed out the issue with multiple CMD entries in the Dockerfile. I'm still trying to wrap my head around that)
SHORT VERSION: I can't bring up my web service with "docker run" because "Worker failed to boot." How can I find out what is failing?
LONG VERSION:
I can run my Django project with gunicorn in the foreground:
(trans3) chris@chi:~/website$ gunicorn --bind 0.0.0.0:8000 hero.wsgi
[2018-07-02 15:18:36 +0000] [21541] [INFO] Starting gunicorn 19.7.1
[2018-07-02 15:18:36 +0000] [21541] [INFO] Listening at: http://0.0.0.0:8000 (21541)
[2018-07-02 15:18:36 +0000] [21541] [INFO] Using worker: sync
[2018-07-02 15:18:36 +0000] [21546] [INFO] Booting worker with pid: 21546
^C
[2018-07-02 15:18:39 +0000] [21541] [INFO] Handling signal: int
[2018-07-02 15:18:39 +0000] [21541] [INFO] Shutting down: Master
I have a small Dockerfile.web for my service:
(trans3) chris@chi:~/website$ cat Dockerfile.web
# start with our Django app image
FROM dockersite:latest
# collectstatic.
CMD python manage.py collectstatic --noinput
# run the server
CMD gunicorn --bind 0.0.0.0:$PORT hero.wsgi
I build my image
(trans3) chris@chi:~/website$ docker build -t dockersite/web -f Dockerfile.web .
Sending build context to Docker daemon 137.5MB
Step 1/3 : FROM dockersite:latest
---> 56b1488f8e27
Step 2/3 : CMD python manage.py collectstatic --noinput
---> Using cache
---> 59585027568d
Step 3/3 : CMD gunicorn --bind 0.0.0.0:$PORT hero.wsgi
---> Using cache
---> c17429800329
Successfully built c17429800329
Successfully tagged dockersite/web:latest
I try to run my image:
(trans3) chris@chi:~/website$ docker run -e PORT=8000 -p 8000:8000 --env-file=.env dockersite/web:latest
[2018-07-02 19:23:26 +0000] [8] [INFO] Starting gunicorn 19.7.1
[2018-07-02 19:23:26 +0000] [8] [INFO] Listening at: http://0.0.0.0:8000 (8)
[2018-07-02 19:23:26 +0000] [8] [INFO] Using worker: sync
[2018-07-02 19:23:26 +0000] [12] [INFO] Booting worker with pid: 12
MEMCACHEDCLOUD_SERVERS not found, using LocMem cache
[2018-07-02 19:23:27 +0000] [8] [INFO] Shutting down: Master
[2018-07-02 19:23:27 +0000] [8] [INFO] Reason: Worker failed to boot.
How can I get more information out of Gunicorn to tell me why it's failing? Is there a logger in Python that I can adjust? (I tried --spew
and got lots of information, none of it useful.)