nodejs express doesn't render html page with ect templating engine when it runs as a docker daemon

am trying to run a node js application that renders HTML pages on ECT templating engine on Docker, the case is that it works just fine once am interacting directly with the running container as below command and run node inside it.

docker run -p 80:5000 -it abdullahshahin/admin-panel bash

but when I run it as a daemon, express shows below error

  • How do I debug “No default robot”?
  • how to save a docker redis container
  • Cant find output of docker import
  • Docker root directory issues
  • Dockerfile build yielding lstat error on ADD
  • what is the most efficient way to maintain a tagged and latest docker image version
  • Error: Failed to lookup view “index” in views directory “/views”

    below is the declaration of ect

    var ectRenderer = ECT({ watch: true, root:'/var/njs/html/views', ext : '.ect' });
    

    also, I tried this

    root: __dirname + '/views' and this root:'./views', nothing helped.

    below is the main app file code, am using MVC on this one

    // DECLARE VARIABLES
    var express = require('express');
    var instance = express();
    var parser = require('body-parser');
    instance.use(parser({strict:false}));
    var commander = require('commander');
    var ECT = require('ect');
    var ectRenderer = ECT({ watch: true, root: __dirname + '/views', ext : '.ect' });
    
        // PROMPTE USERS TO ENTER PORT
        commander.option('-p, --port <n>', 'Port to run server on',parseInt).parse(process.argv);
        if(!commander.port)
        {
            console.log("Please provide a port number");
            process.exit(1);
        }
    
        // EXPRESS USES
        instance.set('view engine', 'ect');
        instance.engine('ect', ectRenderer.render);
        // EXPRESS TO USE ROUTES
        require("./routes/routes.js")(instance);
        //instance.use(parser);
        // EXPRESS TO USE PROMPTED PORT
        instance.listen(commander.port);
    

    below is the Dockerfile content

    FROM        ubuntu
    
    RUN         apt-get update
    
    RUN         apt-get --yes install software-properties-common
    
    RUN         apt-add-repository -y ppa:chris-lea/node.js
    
    RUN         apt-get update
    
    RUN         apt-get --yes install nodejs
    
    COPY . /var/njs/html
    
    RUN cd /var/njs/html; npm install
    
    EXPOSE      1234
    
    CMD node /var/njs/html/app.js -p 1234
    

    has anyone had any thoughts on this ?

  • Docker cannot acces registry from openshift
  • How to continue a docker which is exited
  • What permissions are required for docker host volume?
  • Solution for running scheduled cron job within a Docker container?
  • Why use a data-only container over a host mount?
  • Docker containers as Linux services?
  • One Solution collect form web for “nodejs express doesn't render html page with ect templating engine when it runs as a docker daemon”

    I just found it, I mentioned the working directory with the daemon option when run the container as below

    docker run -p 80:1234 -w="/var/njs/html" -d abdullahshahin/admin-panel
    

    https://docs.docker.com/reference/run/#env-environment-variables

    Docker will be the best open platform for developers and sysadmins to build, ship, and run distributed applications.