Skip to content

Commit 4a8f219

Browse files
committed
Fix docker ipfs ips
1 parent 3f9a21d commit 4a8f219

File tree

2 files changed

+22
-17
lines changed

2 files changed

+22
-17
lines changed

examples/justfile

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -219,21 +219,17 @@ ipfs-start test_dir: _check-docker
219219

220220
# Pull latest kubo image if not present
221221
docker pull ipfs/kubo:latest
222-
223-
# Determine network mode based on OS
224-
if [[ "$OSTYPE" == "darwin"* ]]; then
225-
# macOS - use port mapping
226-
NETWORK_ARGS="-p 4001:4001 -p 8080:8080 -p 5001:5001"
227-
else
228-
# Linux (including CI) - use host networking for direct access
229-
NETWORK_ARGS="--network host -p 4001:4001 -p 8080:8080 -p 5001:5001"
230-
fi
231-
222+
223+
# Use bridge network mode
224+
NETWORK_ARGS="-p 4001:4001 -p 8080:8080 -p 5001:5001"
225+
232226
# Start Docker container
233227
docker run -d --name ipfs-node -v ipfs-data:/data/ipfs $NETWORK_ARGS ipfs/kubo:latest
234228
echo " Container: ipfs-node"
229+
echo " NETWORK_ARGS: $NETWORK_ARGS"
235230
echo " Waiting for container to start..."
236231
sleep 5
232+
docker inspect ipfs-node --format '{{.HostConfig.NetworkMode}}'
237233
docker exec ipfs-node ipfs --version
238234

239235
# Bitswap logging
@@ -257,11 +253,11 @@ ipfs-connect runtime:
257253
PROTOCOL="dns4"
258254
DOCKER_HOST="host.docker.internal"
259255
else
260-
# Linux (with host networking) - use ip4/127.0.0.1
256+
# Linux (with bridge networking) - use ip4/172.17.0.1
261257
PROTOCOL="ip4"
262-
DOCKER_HOST="127.0.0.1"
258+
DOCKER_HOST="172.17.0.1"
263259
fi
264-
260+
265261
echo " Using Docker host: /$PROTOCOL/$DOCKER_HOST"
266262

267263
# TODO: improve this for multiple runtimes

scripts/ipfs-reconnect-westend.sh

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,17 +6,26 @@ THIS_DIR=$(cd $(dirname $0); pwd)
66
mode="${1:-local}"
77
if [ "$mode" = "docker" ]; then
88
check_cmd="docker exec ipfs-node ipfs"
9-
# TODO: what is right? ipfs-reconnect uses 127.0.0.1
10-
check_host="127.0.0.1"
9+
10+
if [[ "$OSTYPE" == "darwin"* ]]; then
11+
# macOS - use dns4/host.docker.internal
12+
check_protocol="dns4"
13+
check_host="host.docker.internal"
14+
else
15+
# Linux (with bridge networking) - use ip4/172.17.0.1
16+
check_protocol="ip4"
17+
check_host="172.17.0.1"
18+
fi
1119
else
1220
check_cmd="${THIS_DIR}/../kubo/ipfs"
21+
check_protocol="ip4"
1322
check_host="127.0.0.1"
1423
fi
1524

1625
# Peers to monitor
1726
PEERS_TO_CHECK=(
18-
"/ip4/${check_host}/tcp/10001/ws/p2p/12D3KooWJKVVNYByvML4Pgx1GWAYryYo6exA68jQX9Mw3AJ6G5gQ"
19-
"/ip4/${check_host}/tcp/12347/ws/p2p/12D3KooWJ8sqAYtMBX3z3jy2iM98XGLFVzVfUPtmgDzxXSPkVpZZ"
27+
"/${check_protocol}/${check_host}/tcp/10001/ws/p2p/12D3KooWJKVVNYByvML4Pgx1GWAYryYo6exA68jQX9Mw3AJ6G5gQ"
28+
"/${check_protocol}/${check_host}/tcp/12347/ws/p2p/12D3KooWJ8sqAYtMBX3z3jy2iM98XGLFVzVfUPtmgDzxXSPkVpZZ"
2029
)
2130

2231
while true; do

0 commit comments

Comments
 (0)