我在 Pod 中运行 nodejs 应用程序(连同 mongo 容器),Nodejs 应用程序侦听端口 3000,我从容器中公开该端口。我已经在 pod 上发布了端口 3000。容器成功启动(已验证日志),但我无法访问主机上的应用程序。当我从 pod 中卷曲到我的应用程序时,它可以工作。容器运行 rootfull,操作系统:CentOS Linux 版本 8.0.1905(核心)。我错过了什么?
curl http://localhost:3000
curl: (7) Failed to connect to localhost port 3000: No route to host
podman ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
30da37306acf registry.gitlab.com/xxx/switchboard:master node main.js 34 minutes ago Up 34 minutes ago 0.0.0.0:3000->3000/tcp switchboard-app
acc08c71147b docker.io/library/mongo:latest mongod 35 minutes ago Up 35 minutes ago 0.0.0.0:3000->3000/tcp switchboard-mongo
podman port switchboard-app
3000/tcp -> 0.0.0.0:3000
app.listen(3000, "0.0.0.0",function () {
console.log('App is listening on port 3000!');
});
FROM node:13
WORKDIR /usr/src/app
COPY package*.json ./
RUN npm install
COPY /dist/apps/switchboard .
EXPOSE 3000
CMD [ "node", "main.js" ]