尝试在个人Mac和Docker digitalocean Droplet上启动openresty docker(https://github.com/3scale/docker-openresty),但收到错误:
DEBG 'openresty' stderr output:
nginx: [emerg] bind() to 0.0.0.0:8080 failed (98: Address already in use)
CONFIGS:
1)Dockerfile
FROM 3scale/openresty
ADD openresty.conf /etc/supervisor/conf.d/
ADD . /var/www
CMD ["supervisord"]
2)Openresty.conf
[program:openresty]
command=/opt/openresty/nginx/sbin/nginx -p /var/www/ -c config/nginx.conf
autorestart=true
3)config / nginx.conf
worker_processes 1;
error_log logs/error.log;
events {
worker_connections 1024;
}
http {
server {
listen 8080;
location / {
default_type text/html;
content_by_lua '
ngx.say("<p>hello, world</p>")
';
}
}
}
我是如何推出的:
docker build -t resty_docker .
docker run resty_docker
结果:
2014-11-02 11:27:01,232 CRIT Supervisor running as root (no user in config file)
2014-11-02 11:27:01,233 WARN Included extra file "/etc/supervisor/conf.d/openresty.conf" during parsing
2014-11-02 11:27:01,233 WARN Included extra file "/etc/supervisor/conf.d/cron.conf" during parsing
2014-11-02 11:27:01,233 WARN Included extra file "/etc/supervisor/conf.d/arping.conf" during parsing
2014-11-02 11:27:01,233 WARN Included extra file "/etc/supervisor/conf.d/redis.conf" during parsing
2014-11-02 11:27:01,260 INFO RPC interface 'supervisor' initialized
2014-11-02 11:27:01,260 WARN cElementTree not installed, using slower XML parser for XML-RPC
2014-11-02 11:27:01,260 CRIT Server 'unix_http_server' running without any HTTP authentication checking
2014-11-02 11:27:01,260 INFO supervisord started with pid 1
2014-11-02 11:27:02,269 INFO spawned: 'cron' with pid 7
2014-11-02 11:27:02,272 INFO spawned: 'arping' with pid 8
2014-11-02 11:27:02,275 INFO spawned: 'redis' with pid 9
2014-11-02 11:27:02,277 INFO spawned: 'openresty' with pid 10
2014-11-02 11:27:02,302 DEBG fd 20 closed, stopped monitoring <POutputDispatcher at 34498968 for <Subprocess at 34067088 with name openresty in state STARTING> (stdout)>
2014-11-02 11:27:02,302 DEBG fd 24 closed, stopped monitoring <POutputDispatcher at 34499328 for <Subprocess at 34067088 with name openresty in state STARTING> (stderr)>
2014-11-02 11:27:02,302 INFO exited: openresty (exit status 0; not expected)
2014-11-02 11:27:02,303 DEBG received SIGCLD indicating a child quit
2014-11-02 11:27:03,306 INFO success: cron entered RUNNING state, process has stayed up for > than 1 seconds (startsecs)
2014-11-02 11:27:03,306 INFO success: arping entered RUNNING state, process has stayed up for > than 1 seconds (startsecs)
2014-11-02 11:27:03,306 INFO success: redis entered RUNNING state, process has stayed up for > than 1 seconds (startsecs)
2014-11-02 11:27:03,308 INFO spawned: 'openresty' with pid 19
2014-11-02 11:27:03,318 DEBG 'openresty' stderr output:
nginx: [emerg] bind() to 0.0.0.0:8080 failed (98: Address already in use)
2014-11-02 11:27:03,820 DEBG 'openresty' stderr output:
nginx: [emerg] bind() to 0.0.0.0:8080 failed (98: Address already in use)
2014-11-02 11:27:04,329 DEBG 'openresty' stderr output:
nginx: [emerg] bind() to 0.0.0.0:8080 failed (98: Address already in use)
2014-11-02 11:27:04,329 INFO success: openresty entered RUNNING state, process has stayed up for > than 1 seconds (startsecs)
2014-11-02 11:27:04,831 DEBG 'openresty' stderr output:
nginx: [emerg] bind() to 0.0.0.0:8080 failed (98: Address already in use)
答案 0 :(得分:3)
好的,问题不在于ONBUILD CMD ["supervisord", "-n"]
,而是在nginx背景和主管杀死它。
将daemon off;
添加到nginx.conf后,问题就消失了。
答案 1 :(得分:0)
您的父容器3scale/openresty具有行ONBUILD CMD ["supervisord", "-n"]
这意味着sypervisord已在运行(有关ONBUILD的详细信息,请参阅here)。当你的supervisord命令运行时,它会发现冲突。