wenjunxiao / mac-docker-connector

The connector provides the ability for the mac/windows host to directly access the docker container

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Mac M2 still cannot connect after configuration

sen-cs opened this issue · comments

commented

docker: 4.21.1
docker-> redis-cluster 7.0.11

$ brew tap wenjunxiao/brew
$ brew install docker-connector

$ docker network ls --filter driver=bridge --format "{{.ID}}" | xargs docker network inspect --format "route {{range .IPAM.Config}}{{.Subnet}}{{end}}" >> "$(brew --prefix)/etc/docker-connector.conf"

sudo brew services start docker-connector
docker run -it -d --restart always --net host --cap-add NET_ADMIN --name connector wenjunxiao/mac-docker-connector

cat /Library/LaunchDaemons/homebrew.mxcl.docker-connector.plist :

<plist version="1.0">
<dict>
	<key>KeepAlive</key>
	<true/>
	<key>Label</key>
	<string>homebrew.mxcl.docker-connector</string>
	<key>LimitLoadToSessionType</key>
	<array>
		<string>Aqua</string>
		<string>Background</string>
		<string>LoginWindow</string>
		<string>StandardIO</string>
		<string>System</string>
	</array>
	<key>ProgramArguments</key>
	<array>
		<string>sudo</string>
		<string>/opt/homebrew/opt/docker-connector/bin/docker-connector</string>
		<string>-config</string>
		<string>etc/docker-connector.conf</string>
	</array>
	<key>RunAtLoad</key>
	<true/>
	<key>StandardErrorPath</key>
	<string>/opt/homebrew/var/log/docker-connector.log</string>
	<key>StandardOutPath</key>
	<string>/opt/homebrew/var/log/docker-connector.log</string>
	<key>WorkingDirectory</key>
	<string>/opt/homebrew</string>
</dict>
</plist>

cat /opt/homebrew//etc/docker-connector.conf:

# addr 192.168.251.1/24
# mtu 1400
# host 127.0.0.1
# port 2511
# route 172.17.0.0/16
# route 172.18.0.0/16
# iptables 172.17.0.0+172.18.0.0
# hosts /etc/hosts .local
# proxy 127.0.0.1:80:80
route 172.17.0.0/16
route 172.20.0.0/16
route 172.19.0.0/16

ping 172.20.0.2
PING 172.20.0.2 (172.20.0.2): 56 data bytes
Request timeout for icmp_seq 0
Request timeout for icmp_seq 1
Request timeout for icmp_seq 2
Request timeout for icmp_seq 3

@sen-cs 看下容器和Mac里面的日志

同样情况, connector容器内部可ping 其他容器以及宿主机,但是宿主机依旧无法 ping 通容器 ip

@fananzha 可以看下日志 /opt/homebrew/var/log/docker-connector.log
image
这里的配置文件跟我实际的不一样,把配置文件复制一份到这个路径
image
重新启动加载成功就行了