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

  • Can not register more than one subdomain this nginx and nginx-proxy with docker container
  • What tool can manage Docker container to start in order?
  • Facing FileNotFoundException while accessing JSON File in classpath using java in docker containers(SprintBootApplication)
  • How to run maven test with mysql running in docker
  • Can't create container on bluemix
  • Codeception web driver (Selenium on Docker) tests not working as unable to see other containers (works on my dev machine though?!)
  • 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 ?

  • Accessing docker containers by hostname when running through Vagrant on Windows
  • Docker Node.js Cron
  • Can't access docker container on port 80 on OSX
  • Get docker container id from container name
  • How to get this to work? Dockerfile FROM {YourPrivateRepo.azurecr.io/some/repo}
  • How to list all the commands that executed on a pulled Docker image?
  • 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.