I'm attempting to recreate the steps in this tutorial in a docker context, ubuntu image installed under coreos running in virtualbox on OS X.
I've set up a Dockerfile that has the following steps:
# 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 out of a relative /etc/
directory:
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 either /var/log/long.out.log
or /var/log/long.err.log
, although both files are present in that directory.
When I load the image with /bin/bash
/, I then try the following:
I can successfully run service supervisor restart
and get Restarting supervisor:
as output.
But when I try to run any functions with supervisorctl
, I get errors, i.e. unix:///var/run/supervisor.sock refused connection
I checked the output of /var/log/supervisor/supervisord.log
and it gives me:
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 suggests that I include a barebones supervisord.conf
file that explicitly points the application to the supervisord.sock
file, so I added the following to the Dockerfile:
# Add supervisor config file
ADD ./etc/supervisord.conf /etc/supervisor/conf.d/supervisord.conf
and then added a supervisord.conf
file that looks like this:
[supervisord]
logfile=/var/log/supervisor/supervisord.log
loglevel=error
nodaemon=false
[supervisorctl]
serverurl = unix:///var/run/supervisord.sock
After including this
long.err.log
or long.out.log
populating in /var/log/
at all. service supervisor restart
, but now when I run supervisorctl
, the error I get is changed to unix:///var/run/supervisord.sock no such file
. I checked the output of /var/log/supervisor/supervisord.log
and it gives me:
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
Thinking that this might be a user permissioning issue, I tried switching the supervisord.conf
file to
[supervisord]
logfile=/var/log/supervisor/supervisord.log
loglevel=error
nodaemon=false
user=nonroot
[supervisorctl]
serverurl = unix:///var/run/supervisord.sock
after adding the following to my Dockerfile
RUN /usr/sbin/useradd --create-home --home-dir /usr/local/nonroot --shell /bin/bash nonroot
but that gets me the following error on compile
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)
Logging into /bin/bash/
and doing a cat
on /var/log/supervisor/supervisord.log
now yields:
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
What is the issue here? I just want to be able to run this shell script via supervisord
and observe its output in the log files.
You are also starting the service - but then not leaving it to run.
RUN sudo service supervisor start
You should probably be running it directly:
CMD ["/usr/bin/supervisord"]
You may also have to/need to add some parameters to that CMD. See: Docker/Supervisord example
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With