Trying to recreate a supervisor tutorial in docker, starting up in error (allowing?)

I am trying to recreate the steps of this tutorial in the context of a docker ubuntu image installed under the kernels running in a virtual box in OS X.

I installed a Docker file that does the following:

# Install docker basics
RUN echo "deb http://archive.ubuntu.com/ubuntu precise main universe" > /etc/apt/sources.list
RUN apt-get update
RUN apt-get upgrade -y

# Install supervisor
RUN apt-get install -y supervisor
RUN mkdir -p /var/run/sshd
RUN mkdir -p /var/log/supervisor
RUN mkdir -p /etc/supervisor/conf.d

# tutorial suite
ADD ./etc/long.sh /usr/local/bin/long.sh
RUN /bin/chmod 0777 /usr/local/bin/long.sh
ADD ./etc/long_script.conf /etc/supervisor/conf.d/long_script.conf

# create supervisord user
RUN /usr/sbin/useradd --create-home --home-dir /usr/local/nonroot --shell /bin/bash nonroot

# start supervisord
RUN sudo service supervisor start

which copies the following files from the relative directory /etc/:

long.sh:

#!/bin/bash
while true
do
    # Echo current date to stdout
    echo `date`
    # Echo 'error!' to stderr
    echo 'error!' >&2
    sleep 1
done

and long_script.conf:

[program:long_script]
command=/usr/local/bin/long.sh
autostart=true
autorestart=true
stderr_logfile=/var/log/long.err.log
stdout_logfile=/var/log/long.out.log

It loads everything correctly, but then there is no corresponding output in /var/log/long.out.logor /var/log/long.err.log, although both files are present in this directory.

When I load an image using /bin/bash/, I then try the following:

  • I can successfully start service supervisor restartand get Restarting supervisor:as output.

  • supervisorctl, , .. unix:///var/run/supervisor.sock refused connection

/var/log/supervisor/supervisord.log, :

2014-03-17 08:54:48,090 CRIT Supervisor running as root (no user in config file)
2014-03-17 08:54:48,090 WARN Included extra file "/etc/supervisor/conf.d/long_script.conf" during parsing
2014-03-17 08:54:48,161 INFO RPC interface 'supervisor' initialized
2014-03-17 08:54:48,161 WARN cElementTree not installed, using slower XML parser for XML-RPC
2014-03-17 08:54:48,161 CRIT Server 'unix_http_server' running without any HTTP authentication checking
2014-03-17 08:54:48,163 INFO daemonizing the supervisord process
2014-03-17 08:54:48,164 INFO supervisord started with pid 10
2014-03-17 08:54:49,165 INFO spawned: 'long_script' with pid 13
[error] client.go:2296 Error resize: Error: resize: bad file descriptor

Googling , barebones supervisord.conf, supervisord.sock, Docker:

# Add supervisor config file
ADD ./etc/supervisord.conf /etc/supervisor/conf.d/supervisord.conf

supervisord.conf, :

[supervisord]
logfile=/var/log/supervisor/supervisord.log
loglevel=error
nodaemon=false

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

  • long.err.log long.out.log, /var/log/.
  • service supervisor restart, , supervisorctl, unix:///var/run/supervisord.sock no such file.

/var/log/supervisor/supervisord.log, :

2014-03-17 08:48:29,715 CRIT Supervisor running as root (no user in config file)[error] client.go:2296 Error resize: Error: resize: bad file descriptor

, , supervisord.conf

[supervisord]
logfile=/var/log/supervisor/supervisord.log
loglevel=error
nodaemon=false
user=nonroot

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

Dockerfile

RUN /usr/sbin/useradd --create-home --home-dir /usr/local/nonroot --shell /bin/bash nonroot

Step XX : RUN service supervisor start
 ---> Running in fdcb12ff3cfa
Traceback (most recent call last):
  File "/usr/bin/supervisord", line 9, in <module>
load_entry_point('supervisor==3.0a8', 'console_scripts', 'supervisord')()
  File "/usr/lib/pymodules/python2.7/supervisor/supervisord.py", line 371, in main
go(options)
  File "/usr/lib/pymodules/python2.7/supervisor/supervisord.py", line 381, in go
d.main()
  File "/usr/lib/pymodules/python2.7/supervisor/supervisord.py", line 88, in main
info_messages)
  File "/usr/lib/pymodules/python2.7/supervisor/options.py", line 1231, in make_logger
stdout = self.nodaemon,
  File "/usr/lib/pymodules/python2.7/supervisor/loggers.py", line 325, in getLogger
handlers.append(RotatingFileHandler(filename,'a',maxbytes,backups))
  File "/usr/lib/pymodules/python2.7/supervisor/loggers.py", line 180, in __init__
FileHandler.__init__(self, filename, mode)
  File "/usr/lib/pymodules/python2.7/supervisor/loggers.py", line 106, in __init__
self.stream = open(filename, mode)

/bin/bash/ cat /var/log/supervisor/supervisord.log :

2014/03/17 08:57:36 build: The command [/bin/sh -c service supervisor start] returned a non-zero code: 1
2014-03-17 08:54:48,090 CRIT Supervisor running as root (no user in config file)
2014-03-17 08:54:48,090 WARN Included extra file "/etc/supervisor/conf.d/long_script.conf" during parsing
2014-03-17 08:54:48,161 INFO RPC interface 'supervisor' initialized
2014-03-17 08:54:48,161 WARN cElementTree not installed, using slower XML parser for XML-RPC
2014-03-17 08:54:48,161 CRIT Server 'unix_http_server' running without any HTTP authentication checking
2014-03-17 08:54:48,163 INFO daemonizing the supervisord process
2014-03-17 08:54:48,164 INFO supervisord started with pid 10
2014-03-17 08:54:49,165 INFO spawned: 'long_script' with pid 13
[error] client.go:2296 Error resize: Error: resize: bad file descriptor

? script supervisord .

+4
3

, sudo . , unix tcp :

[inet_http_server]
port=:9001
[rpcinterface:supervisor]
supervisor.rpcinterface_factory = supervisor.rpcinterface:make_main_rpcinterface
[supervisorctl]
serverurl=http://localhost:9001

localhost (127.0.0.1:9001) .

+3

, .

RUN sudo service supervisor start

, :

CMD ["/usr/bin/supervisord"]

/ CMD. .: /

+2

I know this is a dated question. However, I am sending messages since you have not yet accepted the answer. When working with docker and supervisor, make sure that the supervisor starts in the foreground. You can do this by modifying your supervisord.conf. Set

nodaemon=true
0
source

Source: https://habr.com/ru/post/1532101/


All Articles