supervisor.sock refused connection in docker container

人走茶凉 提交于 2019-12-23 07:46:29

问题


supervisor.sock refused connection in docker container

I have tried to fix it by supervisorctl unix:///var/run/supervisor.sock refused connection AND Overlayfs does not work with unix domain sockets

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


Here is my 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:"]

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"

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

I have tried execute

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

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

How to fix it and let supervisor run in container?


回答1:


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

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]
...

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.

References:

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


来源:https://stackoverflow.com/questions/43753500/supervisor-sock-refused-connection-in-docker-container

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!