[英]Unable to connect to the Docker Container from the host browser on MacOS
I' am trying to deploy docker container on Mac machine.我正在尝试在 Mac 机器上部署 docker 容器。 I ran the command:
我运行了命令:
docker run -P -it clickstream-collector_csapi -c "test_config.yml".
output: ts=2020-02-24T17:25:43Z lvl=info msg="Starting Collector"
ts=2020-02-24T17:25:43Z lvl=info msg="Start producer" service=collector
brokers=kafka.dev:9102
ts=2020-02-24T17:25:44Z lvl=info msg="Starting HTTP service"
ts=2020-02-24T17:25:44Z lvl=info msg="Starting server on" addr=0.0.0.0:13425
However I can't launch 0.0.0.0:13425 on my Mac , it shows me "This site can't be reached0.0.0.0 refused to connect".但是,我无法在 Mac 上启动 0.0.0.0:13425,它显示“无法访问此站点 0.0.0.0 拒绝连接”。 It looks like my local machine doesn't look the docker .
看起来我的本地机器看起来不像 docker 。 I know that Mac has some peculiarities but I pointed -p ( as I thought it should enough).
我知道 Mac 有一些特点,但我指出 -p (因为我认为它应该足够了)。 Thanks a lot beforehand
预先非常感谢
The docker run -P
(capital “P”) option asks Docker to pick a host port. docker run -P
(大写“P”)选项要求 Docker 选择一个主机端口。 That will almost always be a different port number from the one inside the container.这几乎总是与容器内的端口号不同。 You can print out the port number by using
docker ps
to find the container ID, and then docker port 0123456789ab
to print out the actual port mapping.可以通过
docker ps
查找容器 ID 打印出端口号,然后docker port 0123456789ab
打印出实际的端口映射。 Once you've found the port number, you can use the special hostname localhost
or the matching special IP address 127.0.0.1 and that port number to reach your container (not 0.0.0.0, a special address that means “everywhere”).找到端口号后,您可以使用特殊主机名
localhost
或匹配的特殊 IP 地址 127.0.0.1 和该端口号来访问您的容器(不是 0.0.0.0,一个表示“无处不在”的特殊地址)。
In typical use you'll explicitly specify both host and container ports with a -p
(little “p”) option, and also specify a --name
so that you can find the container later.在典型使用中,您将使用
-p
(小“p”)选项显式指定主机和容器端口,并指定一个--name
以便您稍后可以找到容器。
docker run \
-it \
-p 13425:13425 \
--name clickstream_collector \
clickstream-collector_csapi \
...
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.