第一次使用Docker,所以我可能会犯一个菜鸟错误,但这是可行的。我正在尝试使用 reactioncommerce / reaction 图片,它似乎可以正常运行。但是,我似乎无法从主机连接到服务器。
Just using Docker for the first time so I'm probably making a rookie mistake, but here goes. I am trying to use the reactioncommerce/reaction image, and it appears to run correctly. However, I cannot seem to connect to the server from the host.
我正在运行 docker run -p:8080 -it反应,如 Docker Hub页面上所建议,然后尝试通过在主机上的浏览器上转到 http:// localhost:8080 ,但无法建立连接。我要去哪里了?
I am running docker run -p :8080 -it reaction as suggested on the Docker Hub page, then trying to access it by going to localhost:8080 on a browser on the host, but no connection can be made. Where am I going wrong?
我正在Linux Mint主机上运行。
I'm running on a Linux Mint host.
推荐答案我认为您的问题将是您的 -p (发布)标志。假设您的容器实际上在端口8080上侦听-尝试 -p 8080:8080 会将本地主机:8080映射到您的容器。 (嗯,从技术上讲,它将映射 0.0.0.0:8080 ,它是所有地址-包括外部地址)
I think your problem will be your -p (publish) flag. Assuming your container is actually listening on port 8080 - try -p 8080:8080 which will map localhost:8080 to your container. (Well, technically it'll map 0.0.0.0:8080 which is all addresses - including external)
但是我认为,如果您未在左侧指定某些内容,则会得到一个随机映射的端口号-您应该可以在 docker ps 或使用 docker port 命令。
But I think if you're not specifying something on the left hand side, you're getting a random port number mapped - you should be able to see this in docker ps or using the docker port command.
当您运行 docker run -it 时,将以交互方式启动它-并且它应该以 docker file(除非另有说明)。我认为这将是您想要的服务,但我不知道该应用程序。您还可以使用 -d 标志,该标志在后台运行容器。
When you run docker run -it you start it interactively - and it should start 'whatever is defined in the docker file' unless you specify otherwise. I assume this will be a service you want, but I don't know that app. You can also use the -d flag, that runs the container in the background.
更多推荐
无法从主机连接到Docker容器
发布评论