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

  • Do I need a docker-machine with dlite?
  • How to force application's stdout logs through uwsgi?
  • Why am I unable to access my node.js app within a docker container?
  • connecting to docker with curl
  • Docker --add-host flags not working for registry 2.0 webhooks notifications
  • Docker container not mounting data volume
  • 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 ?

  • Passing variables as arguments to docker container
  • Docker with Java: path RUN javac
  • What's the default url that docker using when run `docker pull`?
  • Vagrant: Sync folder with boot2docker box on Windows
  • docker nginx deployment entrypoint
  • Is it possible to run a command when stopping a Docker container?
  • 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.