1

Trying to launch openresty docker ( https://github.com/3scale/docker-openresty ) on personal Mac and on Docker digitalocean droplet, but get an error:

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>")
        ';
    }
}
}

How I launch it:

docker build -t resty_docker .
docker run resty_docker

Result:

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)
4

2 回答 2

3

好的,问题不在于ONBUILD CMD ["supervisord", "-n"],而是 nginx 进入后台并且主管杀死了它。

添加daemon off;到 nginx.conf 后,问题就消失了。

于 2014-11-04T16:03:15.797 回答
0

你的父容器3scale/openresty有这行ONBUILD CMD ["supervisord", "-n"]这意味着 sypervisord 已经在运行(有关ONBUILD 的问题,请参见此处)。当你的 supervisord 命令运行时,它会发现冲突。

于 2014-11-02T23:20:21.240 回答