我已经使用这个 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"]
但是当我使用
$ docker run -d --rm -p 3000:3000 62
运行它时我无法使用 curl http://localhost:3000/About
从 Docker 主机 (OS X) curl 在容器内运行的 API如果我执行到容器中,我会通过 cUrl 从 API 获得有效响应。看起来像容器中的 Linux 防火墙,但我没有看到一个正在运行。
有任何想法吗?
最佳答案
您的节点服务器很可能没有监听所有接口(interface),请确保它绑定(bind)到 0.0.0.0
而不是 127.0.0.1
关于docker - 无法连接到 Docker 镜像中的节点,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53467164/