我正在尝试使用docker-java(https://github.com/docker-java/docker-java)来使用Docker for mac(https://docs.docker.com/docker-for-mac/)。
如何设置相应的:
DOCKER_OPTS="-H tcp://127.0.0.1:2375 -H unix:///var/run/docker.sock"
在Docker的mac版本上?
答案 0 :(得分:6)
有一个相关的答案提出了使用socat
的解决方法。
确实可以在网络上公开端口2375:
socat TCP-LISTEN:2375,reuseaddr,fork UNIX-CONNECT:/var/run/docker.sock
答案 1 :(得分:3)
If you are using the last docker for mac beta, according to issue 25064:
~/Library/Containers/com.docker.docker/Data/database/com.docker.driver.amd64-linux
is a git database.
Note: if ~/Library/Containers/com.docker.docker/Data/database/
does not contain com.docker.driver.amd64-linux
, go to that database/
folder, and do a git reset --hard
.
The daemon configuration is under
etc/docker/daemon.json
, which just uses the config from the Linux configuration file.You need to change the config and then do a
git commit
: docker should restart automatically at that point (if not, restart it) with the new configuration.
As mentioned by the OP Michael Nelson in the comments, and detailed in "Docker for Windows" (which has sections relevant for "Docker for Mac")
The VM (Alpine-based) uses OpenRC as its init system.
The Docker
init
script relies on a/usr/bin/mobyconfig
script.
Thismobyconfig
script requires the kernel to boot with acom.docker.database
label specifying the location of the config file or it bails.The
mobyconfig
script is able to retrievenetwork
andinsecure-registry
configuration for the Docker daemon or pick up a config file from/etc/docker/daemon.json
.
答案 2 :(得分:0)
$码头工人信息
HTTP代理服务器:docker.for.mac.http.internal:3128
HTTPS代理:docker.for.mac.http.internal:3129
注册表:https://index.docker.io/v1/
希望这会有所帮助
答案 3 :(得分:0)
这可能是因为您没有计算机在运行。
eval $(docker-machine env default)
如果输出表明没有默认计算机,则执行
docker-machine create default --driver virtualbox
这将创建一个默认计算机,并且连接将成功。