chipmk / docker-mac-net-connect

Connect directly to Docker-for-Mac containers via IP address 🐳 💻
MIT License
402 stars 41 forks source link

Mac M2 still cannot connect after configuration #30

Open sen-cs opened 1 year ago

sen-cs commented 1 year ago

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