title: attempting to recreate supervisor tutorial in docker, running into error (permissioning?)
body: <p>I'm attempting to recreate the steps in <a href="https://www.digitalocean.com/community/articles/how-to-install-and-manage-supervisor-on-ubuntu-and-debian-vps" rel="nofollow">this tutorial</a> in a docker context, ubuntu image installed under coreos running in virtualbox on OS X.</p>
  
  <p>I've set up a Dockerfile that has the following steps:</p>
  
  <pre><code># Install docker basics
  RUN echo "deb http://archive.ubuntu.com/ubuntu precise main universe" &gt; /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
  </code></pre>
  
  <p>which copies the following files out of a relative <code>/etc/</code> directory:</p>
  
  <p><code>long.sh</code>:</p>
  
  <pre><code>#!/bin/bash
  while true
  do
      # Echo current date to stdout
      echo `date`
      # Echo 'error!' to stderr
      echo 'error!' &gt;&amp;2
      sleep 1
  done
  </code></pre>
  
  <p>and <code>long_script.conf</code>:</p>
  
  <pre><code>[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
  </code></pre>
  
  <p>It loads everything correctly, but then there is no corresponding output in either <code>/var/log/long.out.log</code> or <code>/var/log/long.err.log</code>, although both files are present in that directory.</p>
  
  <p>When I load the image with <code>/bin/bash</code>/, I then try the following:</p>
  
  <ol>
  <li><p>I can successfully run <code>service supervisor restart</code> and get <code>Restarting supervisor:</code> as output.</p></li>
  <li><p>But when I try to run any functions with <code>supervisorctl</code>, I get errors, i.e. <code>unix:///var/run/supervisor.sock refused connection</code></p></li>
  </ol>
  
  <p>I checked the output of <code>/var/log/supervisor/supervisord.log</code> and it gives me:</p>
  
  <pre><code>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
  </code></pre>
  
  <p>Googling suggests that I include a barebones <code>supervisord.conf</code> file that explicitly points the application to the <code>supervisord.sock</code> file, so I added the following to the Dockerfile:</p>
  
  <pre><code># Add supervisor config file
  ADD ./etc/supervisord.conf /etc/supervisor/conf.d/supervisord.conf
  </code></pre>
  
  <p>and then added a <code>supervisord.conf</code> file that looks like this:</p>
  
  <pre><code>[supervisord]
  logfile=/var/log/supervisor/supervisord.log
  loglevel=error
  nodaemon=false
  
  [supervisorctl]
  serverurl = unix:///var/run/supervisord.sock
  </code></pre>
  
  <p>After including this</p>
  
  <ol>
  <li>I no longer have either <code>long.err.log</code> or <code>long.out.log</code> populating in <code>/var/log/</code> at all. </li>
  <li>I am able to run <code>service supervisor restart</code>, but now when I run <code>supervisorctl</code>, the error I get is changed to <code>unix:///var/run/supervisord.sock no such file</code>. </li>
  </ol>
  
  <p>I checked the output of <code>/var/log/supervisor/supervisord.log</code> and it gives me:</p>
  
  <pre><code>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
  </code></pre>
  
  <p>Thinking that this might be a user permissioning issue, I tried switching the <code>supervisord.conf</code> file to</p>
  
  <pre><code>[supervisord]
  logfile=/var/log/supervisor/supervisord.log
  loglevel=error
  nodaemon=false
  user=nonroot
  
  [supervisorctl]
  serverurl = unix:///var/run/supervisord.sock
  </code></pre>
  
  <p>after adding the following to my <code>Dockerfile</code></p>
  
  <pre><code>RUN /usr/sbin/useradd --create-home --home-dir /usr/local/nonroot --shell /bin/bash nonroot
  </code></pre>
  
  <p>but that gets me the following error on compile</p>
  
  <pre><code>Step XX : RUN service supervisor start
   ---&gt; Running in fdcb12ff3cfa
  Traceback (most recent call last):
    File "/usr/bin/supervisord", line 9, in &lt;module&gt;
  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)
  </code></pre>
  
  <p>Logging into <code>/bin/bash/</code> and doing a <code>cat</code> on <code>/var/log/supervisor/supervisord.log</code> now yields:</p>
  
  <pre><code>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
  </code></pre>
  
  <p>What is the issue here? I just want to be able to run this shell script via <code>supervisord</code> and observe its output in the log files.</p>