Convinience docker file with vim installed
dockerfile
# nginx image
FROM nginx
RUN apt-get update
RUN apt-get install -y vim
Build
docker build -t nginx .Run (By default, nginx listens on post 80)
docker run -it -p 80:80 nginx bash
a) Nginx version >
nginx -v
nginx version: nginx/1.15.8
b) Default page which runs upon starting nginx server
/usr/share/nginx/html/index.html
c) Log files
Access logs : Has the details of all the requests made to the server
/var/log/nginx/access.logError logs : Has the details of all the errors made while accessing server
/var/log/nginx/error.log
d) Start server
service nginx start
(or simply hit)nginx
Open localhost on your browser (or hit 127.0.0.1 or local ip address)
You should see the default nginx home page. You can replace the index.html and build your own content
e) Stop server
service nginx stop
f) Reload server
service nginx reload
g) See compile configurations
nginx -V
It will look something like this,
configure arguments: --prefix=/etc/nginx --sbin-path=/usr/sbin/nginx --modules-path=/usr/lib/nginx/modules --conf-path=/etc/nginx/nginx.conf --error-log-path=/var/log/nginx/error.log --http-log-path=/var/log/nginx/access.log --pid-path=/var/run/nginx.pid --lock-path=/var/run/nginx.lock --http-client-body-temp-path=/var/cache/nginx/client_temp --http-proxy-temp-path=/var/cache/nginx/proxy_temp --http-fastcgi-temp-path=/var/cache/nginx/fastcgi_temp --http-uwsgi-temp-path=/var/cache/nginx/uwsgi_temp --http-scgi-temp-path=/var/cache/nginx/scgi_temp --user=nginx --group=nginx --with-compat --with-file-aio --with-threads --with-http_addition_module --with-http_auth_request_module --with-http_dav_module --with-http_flv_module --with-http_gunzip_module --with-http_gzip_static_module --with-http_mp4_module --with-http_random_index_module --with-http_realip_module --with-http_secure_link_module --with-http_slice_module --with-http_ssl_module --with-http_stub_status_module --with-http_sub_module --with-http_v2_module --with-mail --with-mail_ssl_module --with-stream --with-stream_realip_module --with-stream_ssl_module --with-stream_ssl_preread_module --with-cc-opt='-g -O2 -fdebug-prefix-map=/data/builder/debuild/nginx-1.15.8/debian/debuild-base/nginx-1.15.8=. -specs=/usr/share/dpkg/no-pie-compile.specs -fstack-protector-strong -Wformat -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -fPIC' --with-ld-opt='-specs=/usr/share/dpkg/no-pie-link.specs -Wl,-z,relro -Wl,-z,now -Wl,--as-needed -pie'
h) Check if service is running
Identify the pid-path in the configurations. In our case it is
/var/run/nginx.pid
When nginx service is started, this file nginx.pid will be created. When service is stopped, this file will be destroyed. Hence whenever this file doesnt exist, it means no server is running.