Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to check nginx status without systemctl?

Tags:

docker

unix

nginx

I'm running an Nginx webserver in a Alpine container. It appears I cannot use systemctl (https://github.com/moby/moby/issues/2296) without different priviliges, or I get Failed to get D-Bus connection: Unknown error -1. Is there another way to achieve the same thing, i.e. check the status of a running Nginx instance?

like image 291
langkilde Avatar asked Oct 26 '25 06:10

langkilde


2 Answers

you could do ps -ef | grep nginx or netstat -a | grep port_num

assuming the process name for nginx is nginx and port_num is the port your server is running on

like image 51
Calculus Avatar answered Oct 28 '25 22:10

Calculus


Within container nginx usually runs as the only process (actually the master and some workers), not as any kind of service.

As you can see here official nginx alpine Dockerfile nginx even doesn't run as daemon.

If nginx will quit container will stop running. Just use docker ps to check is your container is in running state.

Usually nginx container fail because bad configuration.

nginx within container forwards request and error logs to docker log collector. The best way to find the reasons why nginx container was not able to start is just docker logs <container-name-or-id>

like image 24
Alexander Altshuler Avatar answered Oct 29 '25 00:10

Alexander Altshuler