I'm started to get to know Docker and nginx in docker. I want to use my own custom static files, and my own nginx.conf, so i've created a docker file:
FROM nginx
RUN rm /etc/nginx/nginx.conf
COPY /nginx.conf /etc/nginx/nginx.conf
COPY / /usr/share/nginx/html
# Expose ports
EXPOSE 80
And my nginx.conf:
#user nobody;
worker_processes auto;
#error_log logs/error.log;
#error_log logs/error.log notice;
#error_log logs/error.log info;
#pid logs/nginx.pid;
events {
worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream;
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"'
'$server_name to: $upstream_addr: $request';
access_log logs/access.log main;
sendfile on;
#tcp_nopush on;
#keepalive_timeout 0;
keepalive_timeout 65;
#gzip on;
server {
listen 8080;
server_name 127.0.0.1;
#charset koi8-r;
#access_log logs/host.access.log main;
location / {
root /usr/share/nginx/html;
index index.html index.htm;
try_files $uri /index.html;
include mime.types;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
}
}
I'm building this with:
docker build --no-cache -t nginx-custom .
And running it with:
docker run -d -p 8080:80 --name webserver nginx-custom
But it builds, and then runs, but stopps immediately so if i check with
docker ps -a
I can see it's exited 1 second ago.
I tried to use CMD /usr/sbin/nginx -g "daemon off;"
or deamon off;
in the nginx conf, or use CMD ["nginx", "-g", "daemon off;"]
no matter what i do, it's just exits right after run.