Supervisor.sock拒绝Docker容器中的连接 [英] supervisor.sock refused connection in docker container

查看:284
本文介绍了Supervisor.sock拒绝Docker容器中的连接的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图通过 supervisorctl Unix:///var/run/supervisor.sock拒绝连接 Overlayfs不适用于Unix域套接字

但是,它在我的debain服务器中仍然不起作用。

However, it still does not work in my debain server.

FROM python:2.7

RUN pip install supervisor

RUN mkdir /app
WORKDIR /app

COPY docker_supervisor.conf /app

RUN supervisord -c docker_supervisor.conf

CMD ["supervisorctl", "-c", "docker_supervisor.conf", "restart", "apiapp:"]






这是docker_supervisor.conf




Here is docker_supervisor.conf

[unix_http_server]
file=/var/run/docker_supervisor.sock
chown=root:root
chmod=0777

[supervisord]
logfile=/var/run/docker_supervisor.log
pidfile=/var/run/docker_supervisor.pid

[rpcinterface:supervisor]
supervisor.rpcinterface_factory = 
supervisor.rpcinterface:make_main_rpcinterface

[supervisorctl]
serverurl=unix:///var/run/docker_supervisor.sock

[group:apiapp]
programs=api_web

[program:api_web]
user=root
directory=/app
command=python echo "OKOKOK"



< hr>


sudo docker build --no-cache -t test .
Successfully built c3b4061fc9f7


sudo docker run -v $(pwd):/app test
unix:///var/run/docker_supervisor.sock refused connection

我尝试执行

sudo docker run --tmpfs /var/run -v $(pwd):/app test

但得到的结果是 unix:///var/run/docker_supervisor.sock拒绝连接

But it gets the same result "unix:///var/run/docker_supervisor.sock refused connection"

推荐答案

我只是遇到了同样的问题,并通过将套接字文件路径更改为<$ c $来解决了该问题。 c> /dev/shm/supervisor.sock 。

I just ran into the same issue and solved it by changing the socket file path to /dev/shm/supervisor.sock.

supervisord.conf 文件现在看起来像这样:

The supervisord.conf file now looks like this:

[unix_http_server]
file=/dev/shm/supervisor.sock                 ; <-- change it here
chmod=0700

[supervisord]
nodaemon=true                                 ; <-- add nodaemon for Docker
logfile=/var/log/supervisor/supervisord.log
pidfile=/var/run/supervisord.pid
childlogdir=/var/log/supervisor

[rpcinterface:supervisor]
supervisor.rpcinterface_factory = supervisor.rpcinterface:make_main_rpcinterface

[supervisorctl]
serverurl=unix:///dev/shm/supervisor.sock     ; <-- and change it here too

[program:app]
...

注意:建议将 supervisorctl -c 参数一起使用,以确保它正在读取正确的配置文件。否则,它可能会退回到默认值之一,并尝试使用默认套接字文件 /var/run/supervisor.sock 进行连接,该文件不起作用。

Note: It is recommended to use supervisorctl with the -c argument to make sure that it is reading the correct config file. Otherwise, it might fall back to one of the default ones and try to connect using the default socket file /var/run/supervisor.sock which doesn't work.

编辑-添加了更多注意事项

Edit - added more things to watch for

注2:确保Supervisor服务器在使用客户端之前运行。

Note 2: Make sure Supervisor server is running before using client.

# Start server
supervisord -c /path/to/supervisor.conf
# Then use client
supervisorctl -c /path/to/supervisor.conf status

注3:确保套接字文件存在。如果没有,则可以创建它,例如,像这样(引用):

Note 3: Make sure the socket file exists. If it doesn't, you can create it, for example, like this (reference):

python -c "import socket as s; sock = s.socket(s.AF_UNIX); sock.bind('/dev/shm/supervisor.sock')"

注意4:请记住,也有可能使用TCP代替Unix套接字文件。

Note 4: Keep in mind that it is also possible to use TCP instead of Unix socket file.

[inet_http_server]
port = 127.0.0.1:9001

[supervisorctl]
serverurl = http://127.0.0.1:9001

; Rest of the supervisor.conf file...

引用:

  • https://github.com/Supervisor/supervisor/issues/654
  • https://github.com/moby/moby/issues/12080
  • https://github.com/DataDog/docker-dd-agent/pull/269

这篇关于Supervisor.sock拒绝Docker容器中的连接的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆