Search code examples
dockerdocker-swarmdocker-stack

Docker stack/service doesn't work, how to debug?


I am making stack for docker-swarm.

This is my stack for django and nginx.

I deploy this but it never start.

ID                  NAME                    MODE                REPLICAS            IMAGE                                 PORTS
n9j49jx667x5        django_nginx    replicated          0/1                 nginx:1.13                            *:8000->8000/tcp
7h3sbmmgwbvn        django_python   replicated          0/1                 registry:5000/mydjango:latest   *:8082->8082/tcp
dkzk9z3rdtzm        phpmyadmin_phpmyadmin   global              1/1                 phpmyadmin/phpmyadmin:latest          *:8009->80/tcp
kf6xisbvqdqv        visualizer_app          global              1/1                 dockersamples/visualizer:latest       *:9009->8080/tcp

Now I want to check why this stack dosen't work.

but how can I check the log or some clue??

If service is once works, I can check like

docker container exec -it manager docker service logs -f visualizer_app

But how can I investigate why stack/service doesn't work...??

version: '3'
services:
  python:
    image: registry:5000/mydjango:latest
    command: uwsgi --socket :8001 --module jrtweet.wsgi --py-autoreload 1 --logto /tmp/mylog.log
    volumes: 
      - ./src:/code
      - ./src/static:/static
    ports:
      - "8082:8082"
  nginx:
    image: nginx:1.13
    ports:
      - "8000:8000"
    volumes:
      - ./nginx/conf:/etc/nginx/conf.d
      - ./nginx/uwsgi_params:/etc/nginx/uwsgi_params
      - ./static:/static
    depends_on:
      - python

even I tried the most simple setting, but it doesn't work and I don't even know how to debug.....


I found out the reason why it dosen't work try and error.

I commented out #volumes it works, but this must be a another question...

I still want to know the debug of service launch.....


THanks to taleodor I can found the log service ps

docker container exec -it man docker service ps django_python


mbx47zczllwm        django_python.1       registry:5000/myprog/djangosrc:latest   6b0938c9c5fb        Ready               Rejected less than a second ago   "invalid mount config for type…"   
xgpet2jwwocq         \_ django_python.1   registry:5000/myprog/djangosrc:latest   6b0938c9c5fb        Shutdown            Rejected less than a second ago   "invalid mount config for type…"   
zl1z7a0qx330         \_ django_python.1   registry:5000/myprog/djangosrc:latest   6b0938c9c5fb        Shutdown            Rejected 38 seconds ago           "invalid mount config for type…"   
zewlsc76zluy         \_ django_python.1   registry:5000/myprog/djangosrc:latest   6b0938c9c5fb        Shutdown            Rejected about a minute ago       "invalid mount config for type…"   
zytucyx6unsg         \_ django_python.1   registry:5000/myprog/djangosrc:latest   6b0938c9c5fb        Shutdown            Rejected about a minute ago       "invalid mount config for type…"   
zqjdobhkti47         \_ django_python.1   registry:5000/myprog/djangosrc:latest   6b0938c9c5fb        Shutdown            Rejected about a minute ago       "invalid mount config for type…"   
zxe18cc554ev         \_ django_python.1   registry:5000/myprog/djangosrc:latest   6b0938c9c5fb        Shutdown            Rejected about a minute ago       "invalid mount config for type…"  

Solution

    1. Do docker service ps, i.e.:

      docker service ps django_nginx

    2. This will give you clues about attempts to start server and possible errors. If the error is clear enough, stop there.

    3. If the error is not clear - and containers were started but exited quickly, locate those containers via docker ps and get their logs via

      docker logs container_id