gpt4 book ai didi

docker - Docker堆栈/服务不起作用,如何调试?

转载 作者:行者123 更新时间:2023-12-02 19:19:38 26 4
gpt4 key购买 nike

我正在为docker-swarm创建堆栈。

这是我的django和nginx的堆栈。

我部署了它,但从未开始。

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

现在,我想检查一下为什么这个堆栈不起作用。

但是我该如何查看日志或一些线索呢?

如果服务一次可用,我可以检查
docker container exec -it manager docker service logs -f visualizer_app

但是我如何调查为什么堆栈/服务不起作用...?
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

即使我尝试了最简单的设置,但它不起作用,我什至不知道如何调试.....

我找出了它无法正常工作的原因,尝试并出错。

我将 #volumes注释掉了,但是它必须是另一个问题...

我仍然想知道服务启动的调试.....

对taleodor表示感谢,我可以找到日志 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…"

最佳答案

  • 做docker服务ps,即:

    docker服务ps django_nginx
  • 这将为您提供有关尝试启动服务器以及可能的错误的线索。如果错误足够明显,请在此处停止。
  • 如果错误仍未清除-容器已启动但已快速退出,请通过docker ps找到这些容器,并通过获取它们的日志

    docker 日志container_id
  • 关于docker - Docker堆栈/服务不起作用,如何调试?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60785622/

    26 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com