如何从Ubuntu的容器中wget localhost url?
问题描述:
我有一个Ubuntu的容器运行,但我不能wget本地主机运行我的码头图像。如何从Ubuntu的容器中wget localhost url?
例如,我使用运行docker的lenovo笔记本电脑。然后我登录到我的笔记本电脑来启动并运行一个Ubuntu容器。当我ssh进入Ubuntu的容器,我无法wget本地主机url的。有没有办法将容器连接到本地主机?还有多少种方式可以通过docker容器连接到localhost。
这是错误消息时,我的wget
[email protected]:/openchain# wget 127.0.0.1:8090
converted 'http://127.0.0.1:8090' (ANSI_X3.4-1968) ->
'http://127.0.0.1:8090' (UTF-8)
--2017-09-01 04:41:22-- http://127.0.0.1:8090/
Connecting to 127.0.0.1:8090... failed: Connection refused.
在此先感谢,所有类似这样的问题不回答我的问题,我得到。
答
Dock的mac recently gained a docker.for.mac.localhost(17.06)。
但对于Windows,您可以尝试一些在“How to get the IP address of the docker host from inside a docker container”详细的选项,那就是至少:
run --env <key>=<value>
运行您的容器时,路过的IP是一个简单的方法。
run -e "DOCKER_HOST=$(ip -4 addr show docker0 | grep -Po 'inet \K[\d.]+')"
或者,从 “Insert Docker parent host ip into container's hosts file”
docker run --add-host=dockerhost:`docker network inspect \
--format='{{range .IPAM.Config}}{{.Gateway}}{{end}}' bridge` [IMAGE]