Allow passing the IP address where the router console is reachable when running a Docker container

This commit is contained in:
idk
2022-11-14 18:55:21 +00:00
parent 114694434c
commit d4155625e4
2 changed files with 16 additions and 5 deletions

View File

@ -28,6 +28,17 @@ docker build -t i2p .
### Running a container
#### Environment Variables
It is possible to set the IP address where the I2P router is accessible by setting
the `IP_ADDR` environment variable in your `docker run` command or your `docker-compose`
file. For example, if you want to make your I2P router listen on all addresses, then
you should pass `-e IP_ADDR=0.0.0.0` to your `docker run` command.
It is also possible to configure the memory available to the I2P router using
environment variables. To do this, use the: `JVM_XMX` environment variable by passing,
for example, `-e JVM_XMX=256m`.
#### Volumes
The container requires a volume for the configuration data to be mounted. Optionally, you can mount a separate volume for torrent ("i2psnark") downloads. See the example below.

View File

@ -24,12 +24,13 @@ done
if [ -f /.dockerenv ]; then
echo "[startapp] Running in container"
if [ -z "$IP_ADDR" ]; then
export IP_ADDR=$(hostname -i)
if echo "$IP_ADDR" | grep "172.17"; then
echo "[startapp] Running in docker network"
sed -i "s/127.0.0.1/${IP_ADDR}/g" ./clients.config ./i2ptunnel.config
fi
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
@ -38,4 +39,3 @@ JAVA17OPTS="--add-opens java.base/java.lang=ALL-UNNAMED --add-opens java.base/su
JAVAOPTS="-Djava.net.preferIPv4Stack=false -Djava.library.path=${I2P}:${I2P}/lib -Di2p.dir.base=${I2P} -Di2p.dir.config=${HOME}/.i2p -DloggerFilenameOverride=logs/log-router-@.txt -Xmx$JVM_XMX"
java -cp "${CLASSPATH}" ${JAVA_OPTS} net.i2p.router.RouterLaunch