Bash 试图在docker中重新创建主管教程时出错(许可?)
我正试图在docker环境中重新创建这些步骤,UbuntuImage安装在coreos下,运行在OS X上的virtualbox中 我已经设置了一个Dockerfile,其中包含以下步骤:Bash 试图在docker中重新创建主管教程时出错(许可?),bash,ubuntu,docker,supervisord,coreos,Bash,Ubuntu,Docker,Supervisord,Coreos,我正试图在docker环境中重新创建这些步骤,UbuntuImage安装在coreos下,运行在OS X上的virtualbox中 我已经设置了一个Dockerfile,其中包含以下步骤: # 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 upg
# 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
从相对的/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
和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
它正确地加载了所有内容,但是在/var/log/long.out.log
或/var/log/long.err.log
中没有相应的输出,尽管这两个文件都存在于该目录中
当我用/bin/bash
/加载图像时,我会尝试以下操作:
service supervisor restart
,并将Restarting supervisor:
作为输出supervisorctl
运行任何函数时,都会出现错误,即unix:///var/run/supervisor.sock 拒绝连接
/var/log/supervisor/supervisor.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
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
Google建议我包括一个基本的supervisord.conf
文件,该文件将应用程序显式指向supervisord.sock
文件,因此我在Dockerfile中添加了以下内容:
# 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
,但现在当我运行supervisor CTL
时,我得到的错误更改为unix:///var/run/supervisord.sock 没有这样的文件
李>
我检查了/var/log/supervisor/supervisor.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
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)
这里的问题是什么?我只希望能够通过
supervisord
运行此shell脚本,并在日志文件中观察其输出。您也在启动服务,但不会让它继续运行
RUN sudo service supervisor start
您可能应该直接运行它:
CMD ["/usr/bin/supervisord"]
您可能还必须/需要向该命令添加一些参数。请参阅:我也遇到了这个问题,
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)并添加可选的用户和密码。我知道这是一个过时的问题。然而,我张贴,因为你还没有接受答复。与docker和supervisor合作时,确保在前台运行supervisord。您可以通过更改supervisord.conf来完成此操作。设置
nodaemon=true
看起来可能和什么有关?建议运行apt get install cgroup lite
以消除“错误的文件描述符”错误。它做到了这一点,但其余的问题仍然存在。你为什么要运行supervisorctl?当图像按预期工作时,你会使用它吗?因为在我看来,在调试初始问题时,您会遇到很多新问题。为了帮助你,我在这里写了一篇关于主管/码头工人的博客:这越来越近了,但我仍然有问题。我将Dockerfile更改为CMD[“/usr/bin/supervisord”]
;当我运行sudo docker run-t-I{username}/{image}
时,我没有得到预期的输出,但是sudo docker run-t-I{username}/{image}bin/bash
之后是supervisorctl
错误,指出套接字文件尚未创建(并且没有创建日志)/usr/bin/supervisord
在bash终端内部本地运行,然后supervisorctl
运行预期输出。很明显,在我运行{username}/{image}
时,这是两个版本之间的问题,但我不确定我做错了什么。这与修复配置文件的位置(从“/etc/supervisor/conf.d/supervisor.conf”到“/etc/supervisor.conf”)相结合对我起了作用。谢谢是的,忘了提那件事了。上面的配置应该放在/etc/supervisor.conf
中。如果您扫描OP,您会看到我将其添加到.conf
文件中。不过谢谢你。