Docker running host but not accessible

Hi @sdetweil. I resolved that problem by unistall and re install the node_modules.
now that problem is solved. It is running on the port. But I can’t login in to the sytem. when I enter the username and password it is not authenticating to login the system. when I inspect the page It shows empty response


how do resolve this issue.

what is port 9191? I have not seen that discussed before, we did port 8181 on the last discussion

yes same thing only. i changed 9191 again.

we can change the port number whatever we required right? before I used 8181. Today I changed as 9191

yes, its ok. i just didn’t know…

you get SOME output at 9191? but login fails?
the app is using port 8000 inside the container, right?

this sounds like an app configuration problem…

yes sdetweil. I used port number 8088. Then i am mapping to 9191 while running. How do I
resolve that

i do not know exactly… this sounds like you need to attach to the container and do debugging of your node application…

what part does the authentication and sends its response?

if you run this app on the host an use port 8088 does it work? is it listening on localhost instead or (any)
localhost inside the container is a different location than on the host machine

I do know how to debug in docker. When I try to enter the username and password then click login button nothing is happening. unable to login(empty response in my login page). Yes If I run this app on the localhost:8088 it is working fine.

you should be able to docker attach container_id to get a commandline inside the container

how would you debug on the host? it is the same.

I added console.log stmts to my node application and put the web page in debug mode (ctrl-shift-i) to see the log output

you told to map the port number while running. My port number is 8088. when I try to map i am mapping 8088 into 9191. why I can’t run 8088 as it is same . because my docker file and server.js has the port number as 8088 only.

docker conatiner attach .
json:cannot unmarshal array into go value of type types.ContainerJSON

docker container logs .
Error response from daemon:page not found

This is showing this error. How to resolve this issue

when attempt to sign in

post: net::ERR-Empty_RESPONSE
XHR failed loading
login failed:

but in local host:

XHR: finished loading :GET “http:localhost:8088/login”

login successfull

while running only i am mapping previous 8088 port into 9191 so in my server.js
I just pass the 8088 only. I think due to that problem this type of error is occuring.

if i run it would not affect any problem right? is there anyway to run without mapping the port number

the commands are docker attach container_id and docker logs container_id

you CAN map port 8088 to 8088… depends on what is available on the host…

looks like the application is adding its port number… So, you will have to use port 8088 on the host too…

-p 8088:8088

docker run -d -p 8088 :8088 nitikishu/samplenodejs //is not working

when I map the port

docker run -d -p 8088:8088 nitikishu/samplenodejs site is not reaching somtimes…

If I map with some other port it is working correctly…
docker run -d -p 8089:8088 nitikishu/samplenodejs

docker run -d -p 9191:8088 nitikishu/samplenodejs

It is running on the docker host.

But Now I used -p 8088:8088 for map. application is running. but unable to login

My question is my dockerfile and server.js file has port number as 8088 only, and also mongodb which I connect is my local db only.

env.config file

App_PORT = 8088

From that env file I am taking the MONGODB_URI into server.js


var express = require(‘express’);
var session = require(‘express-session’);
const bodyParser = require(‘body-parser’);
const logger = require(‘morgan’);
const chalk = require(‘chalk’);
const errorHandler = require(‘errorhandler’);
const dotenv = require(‘dotenv’);
const path = require(‘path’);
const mongoose = require(‘mongoose’);
const MongoStore = require(‘connect-mongo’)(session);
const passport = require(‘passport’);
const expressValidator = require(‘express-validator’);
var app = express();
var multer = require(‘multer’);
var request = require(‘request’);
var fs = require(‘fs’)
dotenv.load({ path: ‘.env.Config’ });
app.use(express.static(__dirname + “/public”));
app.set(‘views’, __dirname + ‘\public’);
app.engine(‘html’, require(‘ejs’).renderFile);
app.set(‘view engine’, ‘html’);
mongoose.connection.on(‘error’, () => {
console.log(‘%s MongoDB connection error. Please make sure MongoDB is running.’,‘✗’));

app.set(‘port’, process.env.App_PORT || 3000);
app.listen(app.get(‘port’), () => {
console.log(‘%s server running on port’,‘✓’), app.get(‘port’));
console.log(’ Press CTRL-C to stop\n’);

I do know this port 8088 is mismatching with 9191 ? if so How to do rectify?
Another doubt is in my env file, I am just passing localhost mongodb path

I may think due to this, My application is showing error while login. because login credentials username and password is checking the db. Entered username and password is already exists for that user or not.
if the username and password is correct I am just redirecting/login to the application. otherwise I am showing error message. But this is not happening… May be it is due to that host address right.?

Can you clarify that error and correct the problem?

is mysql server configured to listen to any caller? with --bind-all

also, is some other app on your host using port 8088 (is you test version of app still running when u launch container)

sorry. I am not getting. can you elaborate it.

Hi @sdetweil when I run an application in docker i am unable to login to system. because I am using mongodb connection in my environment file. path is: mongodb://localhost:27107/sampledb it is not connecting

how to connect my local db in docker application

when I run mongo in system installed path , I am getting this :mongodb:// in my mongo command prompt window

If I try to connect using localhost / it is showing mongodb connection is not running error