问题描述
我正在Mac版Docker上构建docker映像,我需要从localhost:9292托管的本地gem存储库中安装一些gem。
我在Dockerfile中有这个
RUN gem install patron -v 0.10.0 --source http://host.docker.internal:9292
但是,gem安装未完成,并引发了Errno::ECONNREFUSED: Connection refused
错误。
我还尝试卷曲到host.docker.internal
并抛出错误Failed to connect to host.docker.internal port 9292: Connection refused
我要去哪里错了?
解决方法
根据documentation host.docker.internal
仅在开发中有效(尽管我不知道Docker守护程序如何确定它是否在生产环境中运行)。我的猜测是您的Docker守护程序在生产模式下运行。
尝试--add-host = google.com:127.0.0.1。它在ubuntu中对我有用。我能够看到cmd中指定的google.com的IP。只需替换dns和ip
针对您的情况:
-add-host = host.docker.internal:127.0.0.1