[英]Can't connect to Node inside Docker image
I've created an image using this Docker file... 我已经使用此Docker文件创建了一个映像...
FROM node:8
# Create application directory
WORKDIR /usr/src/app
# Install application dependencies
# By only copying the package.json file here, we take advantage of cached Docker layers
COPY package.json ./
RUN npm install
# This will install dev dependencies as well.
# If dev dependencies have been set, use --only-production when deploying to production
# Bundle app source code
COPY . .
EXPOSE 3000
CMD ["node", "server.js"]
But when I run it using $ docker run -d --rm -p 3000:3000 62
I can't cUrl the API running inside the container from the Docker host (OS X) using curl http://localhost:3000/About
但是,当我使用
$ docker run -d --rm -p 3000:3000 62
运行它时,我无法使用curl http://localhost:3000/About
从Docker主机(OS X)来控制在容器内部运行的API
If I exec into the container I get a valid response from the API via cUrl. 如果我执行到容器中,则可以通过cUrl从API获得有效的响应。 Looks like a Linux firewall in the container but I don't see one running.
容器中看起来像是Linux防火墙,但我看不到正在运行。
any ideas? 有任何想法吗?
您的节点服务器很可能没有在所有接口上侦听,请确保它绑定到0.0.0.0
而不是127.0.0.1
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.