In console it showing like this:
Job for nginx.service failed because the control process exited with
error code. See "systemctl status nginx.service" and "journalctl -xe"
for details.
I tried following commands:
sudo nginx -t -c /etc/nginx/nginx.conf
and
sudo nginx -t
It is showing success message but nginx server is not restarting.
sudo systemctl status nginx.service
nginx.service - A high performance web server and a reverse proxy server
Loaded: loaded (/lib/systemd/system/nginx.service; enabled; vendor preset: enabled)
Active: failed (Result: exit-code) since Wed 2018-07-18 18:06:51 IST; 11min ago
Process: 28271 ExecStart=/usr/sbin/nginx -g daemon on; master_process on; (code=exited, status=1/FAILURE)
Process: 28259 ExecStartPre=/usr/sbin/nginx -t -q -g daemon on; master_process on; (code=exited, status=0/SUCCESS) Main PID: 5236 (code=exited, status=0/SUCCESS)
nginx error log have this errors
bind() to 0.0.0.0:443 failed (98: Address already in use)
2018/07/18 18:06:49 [emerg] 28271#28271: bind() to [::]:443 failed (98: Address already in use)
2018/07/18 18:06:49 [emerg] 28271#28271: bind() to 0.0.0.0:80 failed (98: Address already in use)
2018/07/18 18:06:49 [emerg] 28271#28271: still could not bind()
Try to run the following two commands:
sudo fuser -k 80/tcp
sudo fuser -k 443/tcp
Then execute
sudo service nginx restart
If that worked, your hosting provider might be installing Apache on your server by default during a fresh install, so keep reading for a more permenant fix. If that didn't work, keep reading to identify the issue.
Run nginx -t and if it doesn't return anything, I would verify Nginx error log. By default, it should be located in /var/log/nginx/error.log.
You can open it with any text editor:
sudo nano /var/log/nginx/error.log
Can you find something suspicious there?
The second log you can check is the following
sudo nano /var/log/syslog
When I had this issue, it was because my hosting provider was automatically installing Apache during a clean install. It was blocking port 80.
When I executed sudo nano /var/log/nginx/error.log I got the following as the error log:
2018/08/04 06:17:33 [emerg] 634#0: bind() to 0.0.0.0:80 failed (98: Address already in use)
2018/08/04 06:17:33 [emerg] 634#0: bind() to [::]:80 failed (98: Address already in use)
2018/08/04 06:17:33 [emerg] 634#0: bind() to 0.0.0.0:80 failed (98: Address already in use)
What the above error is telling is that it was not able to bind nginx to port 80 because it was already in use.
To fix this, you need to run the following:
yum install net-tools
sudo netstat -tulpn
When you execute the above you will get something like the following:
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
tcp 0 0 0.0.0.0:80 0.0.0.0:* LISTEN 1762/httpd
tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 1224/sshd
tcp 0 0 127.0.0.1:25 0.0.0.0:* LISTEN 1528/sendmail:acce
tcp6 0 0 :::22 :::* LISTEN 1224/sshd
You can see that port 80 is blocked by httpd (Apache). This could also be port 443 if you are using SSL.
Get the PID of the process that uses port 80 or 443. And send the kill command changing the <PID> value:
sudo kill -2 <PID>
Note in my example the PID value of Apache was 1762 so I would execute sudo kill -2 1762
Aternatively you can execute the following:
sudo fuser -k 80/tcp
sudo fuser -k 443/tcp
Now that port 80 or 443 is clear, you can start Nginx by running the following:
sudo service nginx restart
It is also advisable to remove whatever was previously blocking port 80 & 443. This will avoid any conflict in the future. Since Apache (httpd) was blocking my ports I removed it by running the following:
yum remove httpd httpd-devel httpd-manual httpd-tools mod_auth_kerb mod_auth_mysql mod_auth_pgsql mod_authz_ldap mod_dav_svn mod_dnssd mod_nss mod_perl mod_revocator mod_ssl mod_wsgi
Hope this helps.
You already have a program listening on the ports. Stop the other program or choose other ports for nginx.
If it's another nginx instance, you can search for it with ps aux | grep nginx and then kill it with kill PID
Related
I'm trying to configure my reverse proxy through nginx using this tutorial, but when I go to restart the nginx server, it throws the following error message:
nginx[12681]: nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)
I checked out the port using netstat, and I have the following result
tcp 0 0 0.0.0.0:80 0.0.0.0:* LISTEN off (0.00/0/0)
What does this mean? When I go to my domain name, it redirects to the Centos page instead of an nginx page I should be getting. How can I configure the file to get it to redirect to nginx?
Edit:
Added httpd status
httpd.service disabled
mysql.service enabled
my_api.service enabled
nginx.service disabled
I get the above errors when I try to start nginx using systemctl
Running netstat -luntp as root showed that nginx had spawned a master process and a worker. Killing those processes solved the issue
I try to start this service but i can´t, the error below occur:
root#zabbix:/home/appliance# systemctl status nginx.service
nginx.service - A high performance web server and a reverse proxy server
Loaded: loaded (/lib/systemd/system/nginx.service; enabled; vendor preset: enabled)
Active: failed (Result: exit-code) since Wed 2018-07-25 18:33:26 UTC; 1min 27s ago
Process: 30040 ExecStart=/usr/sbin/nginx -g daemon on; master_process on; (code=exited, status=1/FAILURE)
Process: 30037 ExecStartPre=/usr/sbin/nginx -t -q -g daemon on; master_process on; (code=exited, status=0/SUCCESS)
Jul 25 18:33:25 zabbix nginx[30040]: nginx: [emerg] listen() to [::]:80, backlog 511 failed (98: Address already in use)
Jul 25 18:33:25 zabbix nginx[30040]: nginx: [emerg] listen() to 0.0.0.0:80, backlog 511 failed (98: Address already in use)
Jul 25 18:33:25 zabbix nginx[30040]: nginx: [emerg] listen() to [::]:80, backlog 511 failed (98: Address already in use)
Jul 25 18:33:26 zabbix nginx[30040]: nginx: [emerg] listen() to 0.0.0.0:80, backlog 511 failed (98: Address already in use)
Jul 25 18:33:26 zabbix nginx[30040]: nginx: [emerg] listen() to [::]:80, backlog 511 failed (98: Address already in use)
Jul 25 18:33:26 zabbix nginx[30040]: nginx: [emerg] still could not bind()
Jul 25 18:33:26 zabbix systemd[1]: nginx.service: Control process exited, code=exited status=1
Jul 25 18:33:26 zabbix systemd[1]: *******Failed to start A high performance web server*** and a reverse proxy server.****
Jul 25 18:33:26 zabbix systemd[1]: nginx.service: Unit entered failed state.
Jul 25 18:33:26 zabbix systemd[1]: nginx.service: Failed with result 'exit-code'.
You already have a process bound to the HTTP port 80. (Specially after upgrading systems! it will start apache2 by default)
So first try this:
sudo service apache2 stop
sudo systemctl restart nginx
If problem is not solved then run this command sudo lsof -i:80 to get a list of processes using the port and then stop or disable web server.
Try to stop the process which are using the port 80 using:
sudo fuser -k 80/tcp
sudo systemctl restart nginx
In some cases it may be some issues in the configuration file.
You can use nginx -t -c /etc/nginx/nginx.conf command to find any miss-configuration.
In some cases this error is caused by a default Nginx site already on port 80. Removing default config works if you don't need a default one!
sudo rm /etc/nginx/sites-enabled/default
sudo service nginx restart
For me this error was caused by a default nginx site already on port 80. Removing default site worked
sudo rm /etc/nginx/sites-enabled/default
sudo service nginx restart
You already have a process bound to the HTTP port 80.
You can run command sudo lsof -i:80 to get a list of processes using the port and then stop/disable web server.
Try to stop the process which are using the port 80:
sudo fuser -k 80/tcp
Try to stop the process which is using port 80:
sudo fuser -k 80/tcp
When you did restart using
sudo systemctl restart nginx
It may be some issues in the configuration file. You can use this
nginx -t -c /etc/nginx/nginx.confcommand to find any bugs in the configuration file. If you find the bugs resolve that run the sudo service nginx restart again. It will work.
Please check the reference here
In my experience, this error can be triggered in several different situations (which might have the same root, but are perceived as different scenarios).
Not only port 80
Depending on your nginx config, you should also try port 443:
sudo lsof -i:80
sudo lsof -i:443
You should be able to check your nginx listen ports in /etc/nginx/sites-enabled (under Debian)
Special case
In my case, there was an nginx instance running, that would block itself from restarting. It would not go down with sudo systemctl stop nginx. I had to use sudo killall nginx and could then use sudo systemctl start nginx.
Config error
I also experienced the exact same error message on a config error.
You can check your nginx config with /usr/sbin/nginx -c /etc/nginx/nginx.conf# (this will also test all virtual host files (/etc/nginx/sites-enabled`)
i had same issue, was because i have apache and nginx on same server !
so when i typed sudo reboot it didn't work because it started apache while am using nginx so i just run this two commands
sudo systemctl stop apache2
then
sudo systemctl start nginx
then sudo systemctl disable apache2
so next time i reboot not going to face same issue
help from aws services support
I had to use:
sudo killall nginx
And could then use;
sudo systemctl start nginx
For me stopping apache service solved the problem
sudo service apache2 stop
I had this problem too. I checked the /etc/nginx/site-available/default file and I have forgotten to close the bracket (syntax error).
Just restart the nginx server. It should resolve your problem
sudo systemctl restart nginx
I was using gunicorn with nginx, found that service was not active.
sudo systemctl enable gunicorn.socket
sudo systemctl start gunicorn.socket
sudo systemctl restart nginx
Worked for me.
if your gunicorn is active, please make sure it's working fine.
you can also go through the logs(errors) via nginx logs from
sudo tail -f /var/log/nginx/error.log
Certbot and nginx versions:
certbot installed using certbot.eff.org install guide.
Certbot version: 0.22.2
Nginx version: 1.10.3
Getting ssl certificates works fine:
certbot --nginx
But, in renewal of cerbot certificated
certbot renew --dry-run
nginx fails to start causing:
nginx: [error] open() "/run/nginx.pid" failed (2: No such file or directory)
I have tried changing post-hook and pre-hook in /etc/letsencrypt/renewal/*com.conf/
commenting installer=nginx
changing authenticator to nginx and standalone
Adding post and pre hooks in /etc/letsencrypt/renewal-hooks/pre/ and /etc/lestencrypt/renewal-hooks/post/ to stop and start nginx service.
Seems nginx is not starting properly or isn't stop properly.
after renewal completes nginx fails with (code=exited, status=1/FAILURE)
Nginx error log show:
Error while certbot renew:
Try to execute:
sudo service nginx restart
Then test your nginx configuration file(s) (until you see "nginx: configuration file /etc/nginx/nginx.conf test is successful")
sudo nginx -s reload -t
Pay attention on paths to certificates, and other stuff
and then reload configuration without -t option:
sudo nginx -s reload
It's not recommended to modify configuration files in /etc/letsencrypt/ but creating (if it doesn't exist) and modifying cli.ini file here is working for me. You can specify post-hook in this file once and it will work for all your certificates, see my current file:
# /etc/letsencrypt/cli.ini
max-log-backups = 0
authenticator = webroot
webroot-path = /var/www/html
post-hook = service nginx reload
text = True
I hope this will help future readers. Solution source is here (however the article is in Russian)
I had the same issue on Ubuntu 16.04
I've just removed post and pre hooks in /etc/letsencrypt/renewal/*.conf and changed authenticator to nginx - I had in two entries standalone.
And it is working now fine.
Edit:
Recommended way to update renewal config is to reissue new certificate using:
certbot -i nginx -d example.com -d www.example.com certonly
You can run this command line before run reload nginx.
sudo nginx -c /etc/nginx/nginx.conf
or
sudo nginx -c /usr/local/etc/nginx/nginx.conf
then you can start nginx nomaly
sudo nginx -s reload
Good luck.
I had the same error...
When I installed certbot, I followed the instructions and put in a cronjob (5 3 15 * *):
certbot renew --pre-hook "service nginx stop" --post-hook "service nginx start"
this morning nginx was dead, and the log showed
open() "/run/nginx.pid" failed (2: No such file or directory)
I did not connect the two, but do I understand that certbot triggers the nginx failure?
ps -ef | grep nginx, find all nginx process
sudo kill -9 xxx xxx xxx or sudo pkill nginx
sudo systemctl restart nginx
sudo nginx -t
I had this problem and followed a similar tack to those outlined here.
I had had certbot install a certificate, but it was in certonly --nginx mode, I supplied my own nginx serverblocks. certbot worked, but an nginx failure cast doubt on the accuracy of my provisioning.
This certbot call "restarts" nginx with a modified server block configuration, so it can answer the HTTP-01 challenges. I know this because when it fails, it will log, "nginx restart failed:" just before the bind() failures I'm about to show. My nginx server was down when provisioning succeeded.
I couldn't get systemctl or service to start it and systemd status nginx would only ever show "failed".
Whilst I could get nginx up, and serving, with nginx -s reload I wanted systemd to manage it for me.
No amount of systemctl {start|restart|stop|quit} nginx, would work. The status remained as failed and would show errors with bind():
Oct 07 10:04:13 HostXYZ systemd[1]: Starting A high performance web server and a reverse proxy server...
Oct 07 10:04:13 HostXYZ nginx[17096]: nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Unknown error)
Oct 07 10:04:13 HostXYZ nginx[17096]: nginx: [emerg] bind() to [::]:80 failed (98: Unknown error)
Oct 07 10:04:13 HostXYZ nginx[17096]: nginx: [emerg] bind() to [::]:443 failed (98: Unknown error)
Oct 07 10:04:13 HostXYZ nginx[17096]: nginx: [emerg] bind() to 0.0.0.0:443 failed (98: Unknown error)
That would repeat in journalctl output, 4 or 5 times.
I checked the process and saw:
:~$ ps aux | grep nginx
root 12960 0.0 0.6 77216 9816 ? Ss Oct06 0:00 nginx: master process nginx -c /etc/nginx/nginx.conf
www-data 16944 0.0 0.5 77360 8604 ? S 08:43 0:00 nginx: worker process
That process, which appeared to be occupying the ports needed by my systemd service. My systemd service doesn't use that -c /etc/nginx/nginx.conf. It uses:
ExecStart=/usr/sbin/nginx -g 'daemon on; master_process on;'
nginx -s stop, and quit would not rid me of the rogue process. Instead they both gave the error the OP had:
:~$ sudo nginx -s stop
nginx: [error] open() "/run/nginx.pid" failed (2: No such file or directory)
Both my systemd service unit and /etc/nginx/nginx.conf gave /run/nginx.pid as the PIDFile/pid. For some reason, /etc/nginx/nginx.conf wasn't creating it.
What I needed to do:
sudo killall nginx
sudo systemctl start nginx
That knocked out the other nginx service (I think it came from nginx -s reload but I couldn't shut it down by the corollary command) Which looked like this:
:~$ sudo killall nginx
:~$ ps aux | grep nginx
john 17140 0.0 0.1 4008 2004 pts/0 S+ 10:10 0:00 grep --color=auto nginx
:~$ sudo systemctl start nginx
:~$ sudo systemctl status nginx
● nginx.service - A high performance web server and a reverse proxy server
Loaded: loaded (/lib/systemd/system/nginx.service; enabled; vendor preset: enabled)
Active: active (running) since Fri 2022-10-07 10:10:25 UTC; 1s ago
...
:~$ ps aux | grep nginx
root 11481 0.0 0.1 76484 2588 ? Ss 10:10 0:00 nginx: master process /usr/sbin/nginx -g daemon on; master_process on;
www-data 11482 0.0 0.2 76876 4284 ? S 10:10 0:00 nginx: worker process
:~$ cat /run/nginx.pid
11481
I search some other posts about this title
But I can't find the solution to solve this problem.
I have two dockers on my CentOS7 host.
One is for a flask app, and another is for a jupyterhub.
Now there is a error:
nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)
Below is some hint infomation
lsof -i :80
I guess maybe here is the problem, but I don't know how to solve it.
[root#localhost ~]# lsof -i :80
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
nginx 683 root 6u IPv4 15547 0t0 TCP *:http (LISTEN)
nginx 683 root 7u IPv6 15548 0t0 TCP *:http (LISTEN)
nginx 685 nginx 6u IPv4 15547 0t0 TCP *:http (LISTEN)
nginx 685 nginx 7u IPv6 15548 0t0 TCP *:http (LISTEN)
/etc/supervisord.conf
[program:app]
command=/home/flaskproject/venv/bin/gunicorn -w 4 -b 0.0.0.0:6008 manage:app
directory=/home/flaskproject
startsecs=0
stopwaitsecs=0
autostart=true
autorestart=true
stdout_logfile=/home/flaskproject/log/gunicorn.log
stderr_logfile=/home/flaskproject/log/gunicorn.err
[program:nginx]
command=/usr/sbin/nginx -g "daemon off;"
startsecs=0
stopwaitsecs=0
autostart=true
autorestart=true
stdout_logfile=/home/flaskproject/log/nginx.log
stderr_logfile=/home/flaskproject/log/nginx.err
tail -n 30 /etc/supervisord.log
[root#localhost conf.d]# tail -n 30 /tmp/supervisord.log
2016-04-20 15:23:34,176 INFO success: nginx entered RUNNING state, process has stayed up for > than 0 seconds (startsecs)
2016-04-20 15:23:36,678 INFO exited: nginx (exit status 1; not expected)
2016-04-20 15:23:37,680 INFO spawned: 'nginx' with pid 16672
2016-04-20 15:23:37,691 INFO success: nginx entered RUNNING state, process has stayed up for > than 0 seconds (startsecs)
2016-04-20 15:23:40,192 INFO exited: nginx (exit status 1; not expected)
2016-04-20 15:23:41,195 INFO spawned: 'nginx' with pid 16675
2016-04-20 15:23:41,205 INFO success: nginx entered RUNNING state, process has stayed up for > than 0 seconds (startsecs)
2016-04-20 15:23:43,706 INFO exited: nginx (exit status 1; not expected)
2016-04-20 15:23:44,709 INFO spawned: 'nginx' with pid 16676
2016-04-20 15:23:44,719 INFO success: nginx entered RUNNING state, process has stayed up for > than 0 seconds (startsecs)
2016-04-20 15:23:47,222 INFO exited: nginx (exit status 1; not expected)
2016-04-20 15:23:47,819 INFO spawned: 'nginx' with pid 16782
2016-04-20 15:23:47,822 INFO success: nginx entered RUNNING state, process has stayed up for > than 0 seconds (startsecs)
2016-04-20 15:23:47,822 INFO waiting for nginx, manage to die
2016-04-20 15:23:47,822 WARN killing 'manage' (682) with SIGKILL
2016-04-20 15:23:47,834 WARN killing 'manage' (682) with SIGKILL
2016-04-20 15:23:47,834 INFO stopped: manage (terminated by SIGKILL)
2016-04-20 15:23:47,837 WARN killing 'nginx' (16782) with SIGKILL
2016-04-20 15:23:47,837 WARN received SIGTERM indicating exit request
2016-04-20 15:23:47,837 WARN killing 'nginx' (16782) with SIGKILL
2016-04-20 15:23:47,837 INFO stopped: nginx (terminated by SIGTERM)
2016-04-20 15:24:18,949 CRIT Supervisor running as root (no user in config file)
2016-04-20 15:24:19,292 INFO RPC interface 'supervisor' initialized
2016-04-20 15:24:19,292 CRIT Server 'unix_http_server' running without any HTTP authentication checking
2016-04-20 15:24:19,293 INFO daemonizing the supervisord process
tail -f /var/log/nginx/error.log
[root#localhost ~]# tail -f /var/log/nginx/error.log
2016/04/20 15:49:19 [emerg] 2442#0: bind() to [::]:80 failed (98: Address already in use)
2016/04/20 15:49:19 [emerg] 2442#0: bind() to 0.0.0.0:8008 failed (98: Address already in use)
2016/04/20 15:49:19 [emerg] 2442#0: bind() to 0.0.0.0:80 failed (98: Address already in use)
2016/04/20 15:49:19 [emerg] 2442#0: bind() to [::]:80 failed (98: Address already in use)
2016/04/20 15:49:19 [emerg] 2442#0: bind() to 0.0.0.0:8008 failed (98: Address already in use)
2016/04/20 15:49:19 [emerg] 2442#0: bind() to 0.0.0.0:80 failed (98: Address already in use)
2016/04/20 15:49:19 [emerg] 2442#0: bind() to [::]:80 failed (98: Address already in use)
2016/04/20 15:49:19 [emerg] 2442#0: bind() to 0.0.0.0:8008 failed (98: Address already in use)
2016/04/20 15:49:19 [emerg] 2442#0: still could not bind()
I am trying to get the default webpage from nginx loaded but I cannot connect to port 80 over http after the container is running.
I am running docker 1.9.9
The steps I took are as followed:
I created a Docker file that this:
FROM ubuntu:15.10
RUN echo "Europe/London" > /etc/timezone
RUN dpkg-reconfigure -f noninteractive tzdata
ENV DEBIAN_FRONTEND noninteractive
RUN apt-get update
RUN apt-get install -y nginx
RUN apt-get install -y supervisor
RUN apt-get update && apt-get -q -y install lsof
RUN apt-get install net-tools
RUN apt-get install psmisc
RUN apt-get -y install curl
ADD supervisor.nginx.conf /etc/supervisor.d/nginx.conf
CMD /usr/bin/supervisord -n
RUN rm -Rf /etc/nginx/conf.d/*
RUN rm /etc/nginx/sites-enabled/default
RUN mkdir /etc/nginx/logs/
RUN touch /etc/nginx/logs/error.log
RUN mkdir /usr/share/nginx/logs/
RUN touch /usr/share/nginx/logs/error.log
ADD ./conf/nginx.conf /etc/nginx/sites-available/default
RUN ln -s /etc/nginx/sites-available/default /etc/nginx/sites-enabled/default
copy ./dist /usr/share/nginx/html
CMD /usr/bin/supervisord -n
THe docker file copies the nginx config file below into /etc/nginx/sites-available/default and creates a symlink to this file for /etc/nginx/sites-enabled/default.
server {
root /usr/share/nginx/html;
index index.html index.htm;
# redirect server error pages to the static page /50x.html
#
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/html;
}
location ~* \.(jpg|jpeg|gif|png|css|js|ico|xml)$ {
access_log off;
log_not_found off;
expires 5d;
}
# deny access to . files, for security
#
location ~ /\. {
access_log off;
log_not_found off;
deny all;
}
}
I then built the image with:
docker build -t dnginx
I started the container with:
docker run --name d3 -d -p 80:80 dnginx
I then found the ip address and tried to connect
curl http://172.17.0.2
Which returned
curl: (7) Failed to connect to 172.17.0.2 port 80: Operation timed out
I opened a bash shell in the container and ran nginx which returned:
nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)
nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)
nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)
nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)
nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)
nginx: [emerg] still could not bind()
If I run netstat --listen I get:
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address Foreign Address State
tcp 0 0 *:80 *:* LISTEN
If I run netstat -ltnp | grep :80 I get:
tcp 0 0 0.0.0.0:80 0.0.0.0:* LISTEN -
I have absolutely no idea what is happening.
The same thing happens if I connect just to the nginx image.
I have the same issue these days, but i have to run multi-process, so removing supervisord is not a solution for me.
Simply add -g "daemon off;" flag to supervisor nginx program command solves the problem. That is
[program:nginx]
command=/usr/sbin/nginx -g "daemon off;"
It seems that all process in a container must be run in the foreground, even managed by supervisord tools
I've tried your Dockerfile and it has worked as expected. The only changes I made were removing anything referring to supervisord and adding
CMD ["nginx", "-g", "daemon off;"]
at the end of the Dockerfile.
When a container starts, its networking namespace is completely isolated from the host and from the other containers, and the only processes are the one started by the ENTRIPOINT or CMD directives and its children, so I think that the nginx process that you see running in the container is exactly the one which is run by supervisord.
Are you sure that 172.17.0.2 is the current IP of the docker container?
The container IP is not stable, and it varies depending on how many containers are running on your host and the order on which they have been started.
You expose the http port on the host with the run option '-p 80:80', so you should be able to access it on docker host using curl 127.0.0.1.