내 Hapi 응용 프로그램이 Docker 컨테이너에서 실행되고 있지만 브라우저에서 해당 응용 프로그램이 실행되지 않는 것 같습니다. 나는 docker run -d -p 8080:3000
이 그것을했을 것이라고 생각했지만, 나는 그렇지 않을 것입니다. 나는 도커에게 시동을 걸고 있는데 http://localhost:8080/hello
도 아니고 http://192.168.99.100:8080/hello
도 작동하지 않습니다.Node Docker가 실행되었지만 응용 프로그램을 볼 수 없음
나는 이것에 대한 많은 변형을 시도했다.
Server running at: http://localhost:8080
가 여기 내 Hapi.js 서버의 :
'use strict';
const Hapi = require('hapi');
// Create a server with a host and port
const server = Hapi.server({
host: 'localhost',
port: 3000
});
// Add the route
server.route({
method: 'GET',
path:'/hello',
handler: function (request, h) {
return 'hello world';
}
});
async function start() {
try {
await server.start();
}
catch (err) {
console.log(err);
process.exit(1);
}
console.log(`App running at: ${server.info.uri}/hello`);
}
start();
가 여기 내 Dockerfile입니다 :
FROM node:8.9.3
MAINTAINER My Name <[email protected]>
ENV NODE_ENV=production
ENV PORT=3000
ENV user node
WORKDIR /var/www
COPY package.json yarn.lock ./
RUN cd /var/www && yarn
COPY . .
EXPOSE $PORT
ENTRYPOINT ["yarn", "start"]
가 여기 내 패키지의
이 내가 docker inspect <container id>
을 실행할 때 내가 볼 것입니다. json :
{
"name": "my-app",
"version": "1.0.0",
"repository": "https://github.com/myname/myrepo.git",
"author": "My Name",
"license": "MIT",
"private": true,
"dependencies": {
"hapi": "17.2.0"
},
"scripts": {
"start": "node ./src/server"
}
}