【发布时间】:2020-01-14 15:27:18
【问题描述】:
我添加了防火墙规则以打开端口 8080。如果我在 GCE 控制台中单击 SSH 按钮,并在主机 shell 上运行:
nc -l -p 8080 127.0.0.1
我可以检测到打开的端口。如果我然后去容器的外壳:
docker run --rm -i -t <image> /bin/sh
并运行相同的 netcat 命令,我无法检测到打开的端口。
我走上了这条故障排除路线,因为我无法连接到运行 ws npm 的 node:alpine 容器,用于演示 websocket 服务器。这是我的 dockerfile:
# specify the node base image with your desired version node:<version>
FROM node:alpine
# replace this with your application's default port
EXPOSE 8080
WORKDIR /app
RUN apk --update add git
【问题讨论】:
-
docker run --rm -i -t -p 8080:8080 <image> /bin/sh。将容器中的端口暴露给主机。 -
是的,已修复,谢谢!
标签: docker google-cloud-platform network-programming google-compute-engine netcat