supervisor.sock在docker容器中拒绝连接

时间:2017-05-03 07:14:00

标签: python unix docker dockerfile supervisor

supervisor.sock在docker容器中拒绝连接

我试图通过supervisorctl unix:///var/run/supervisor.sock refused connectionOverlayfs does not work with unix domain sockets

来修复它

但是,它仍然无法在我的debain服务器中运行。

这是我的docker_supervisor.conf

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

[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"
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拒绝连接”

如何修复它并让主管在容器中运行?

1 个答案:

答案 0 :(得分:0)

我遇到了同样的问题,并通过将套接字文件路径更改为/dev/shm/supervisor.sock来解决了这个问题。

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

[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进行连接,而该套接字文件无效。

参考文献: