node.js - How to run nodejs inside container correctly? -
i have docker image consist of nginx server index.html
file following config:
server { listen 80; server_name mysite; root /var/www/application; index index.html; }
no need add nodejs handle /api/
location following:
upstream api_node_js { server 127.0.0.1:3000; } server { listen 80; server_name mysite; root /var/www/application; index index.html; } location /api { proxy_set_header x-real-ip $remote_addr; proxy_set_header x-forwarded-for $proxy_add_x_forwarded_for; proxy_set_header host $http_host; proxy_set_header x-nginx-proxy true; rewrite ^/api/?(.*) /$1 break; proxy_pass http://api_node_js; proxy_redirect off; }
so need install , run nodejs server on 3000
handle api requests. question how should run correctly?
i've tried add running via forever following command in dockerfile:
workdir /var/www/application cmd ["forever", "start", "server.js"]
but unfortunately after starting of container exited no errors.
please me i'm doing wrong?
while @ilyapt right, , should separate nginx , node 2 containers, not answer question. should omit start
docker cmd, prevent forever running in background - causing container exit.
try changing last line in dockerfile - cmd ["forever", "server.js"]
, see if helps.
Comments
Post a Comment