Skip to content

Commit

Permalink
Docker: automatically resolve conflicting port issues when the extern…
Browse files Browse the repository at this point in the history
…al port used by docker does not match the port in the routerInfo
  • Loading branch information
eyedeekay committed Sep 29, 2024
1 parent 8681985 commit 9154945
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 9 deletions.
17 changes: 9 additions & 8 deletions Docker.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
If you just want to give I2P a quick try or are using it on a home network, follow these steps:

1. Create two directories `i2pconfig` and `i2ptorrents`
2. Copy the following text and save it in a file `docker-compose.yml`
2. Create an `.env` file containing the `EXT_PORT` environment variable.
3. Copy the following text and save it in a file `docker-compose.yml`
```
version: "3.5"
services:
Expand All @@ -14,14 +15,14 @@ services:
- 127.0.0.1:4444:4444
- 127.0.0.1:6668:6668
- 127.0.0.1:7657:7657
- 54321:12345
- 54321:12345/udp
- "$EXT_PORT":"$EXT_PORT"
- "$EXT_PORT":"$EXT_PORT"/udp
volumes:
- ./i2pconfig:/i2p/.i2p
- ./i2ptorrents:/i2psnark
```
3. Execute `docker-compose up`
4. Start a browser and go to `http://127.0.0.1:7657` to complete the setup wizard.
4. Execute `docker-compose up`
5. Start a browser and go to `http://127.0.0.1:7657` to complete the setup wizard.

Note that this quick-start approach is not recommended for production deployments on remote servers. Please read the rest of this document for more information.

Expand Down Expand Up @@ -81,13 +82,13 @@ docker build -t geti2p/i2p .
# I2NP port needs TCP and UDP. Change the 54321 to something random, greater than 1024.
docker run \
-e JVM_XMX=256m \
-e EXT_PORT=54321 \
-v i2phome:/i2p/.i2p \
-v i2ptorrents:/i2psnark \
-p 127.0.0.1:4444:4444 \
-p 127.0.0.1:6668:6668 \
-p 127.0.0.1:7657:7657 \
-p 54321:12345 \
-p 54321:12345/udp \
-p "$EXT_PORT":"$EXT_PORT" \
-p "$EXT_PORT":"$EXT_PORT"/udp \
geti2p/i2p:latest
```

10 changes: 9 additions & 1 deletion docker/rootfs/startapp.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,14 @@ if [ -z $JVM_XMX ]; then
JVM_XMX=512m
fi

if [ -z $EXT_PORT ]; then
echo "*** EXT_PORT is unset."
echo "*** I2P router will resolve to a \"Firewalled\" state"
echo "*** please configure EXT_PORT in your docker-compose.yaml or docker run command"
else
find . -name 'router.config' -exec sed -i "s|12345|$EXT_PORT|g" {} \;
fi

# Explicitly define HOME otherwise it might not have been set
export HOME=/i2p

Expand All @@ -31,7 +39,7 @@ if [ -f /.dockerenv ] || [ -f /run/.containerenv ]; then
echo "[startapp] setting reachable IP to container IP $IP_ADDR"
find . -name '*.config' -exec sed -i "s/127.0.0.1/$IP_ADDR/g" {} \;
find . -name '*.config' -exec sed -i "s/localhost/$IP_ADDR/g" {} \;

fi

# Options required for reflective access in dynamic JVM languages like Groovy and Jython
Expand Down

0 comments on commit 9154945

Please sign in to comment.