Hi so I’m following the docker compose section on Installing I2P in Docker, the docker image pulls and deploys fine but how do I make it so the router is accessible outside its own network as can’t get to http://127.0.0.1:7657/ as the container is running inside a virtual machine. Is there any way to change the config so I can access the router via the LAN IP address instead of the loopback IP?
Also not a docker user, but I notice the tutorial states:
That means that the services in the list above which are bound to 127.0.0.1 (which include the router console) will need to be accessed via other methods like ssh tunneling or be manually configured to bind to a different interface.
What is your host OS? On linux you can use iptables/nftables to setup a forward.
A bit late, but I got a similar issue today. Depending from which image you are using, you may need to specify what ports are exposed and where :
docker-compose
if you are using the recommended docker-compose file [1]:
version: "3.5" services: i2p: image: geti2p/i2p network_mode: host volumes: - ./i2pconfig:/i2p/.i2p - ./i2ptorrents:/i2psnark
You have to remove the line
network_mode: host
and add a port exposition, something like that :version: "3.5" services: i2p: image: purplei2p/i2pd volumes: - ./i2pconfig:/i2p/.i2p - ./i2ptorrents:/i2psnark ports: - "7567:7657"
You may have to add other ports, please refer to the official documentation : https://geti2p.net/en/download/docker#ports
Warning : It seems that network_mode: host is a security parameter, maybe to not expose too much of your infrastructure. I don’t get everything yet, but you may disconnect your server from internet during configuration, and this line after. There may be other solution, such as reverse proxy or ssh tunneling that you may have to try.
From the same directory, you could launch it with :
docker-compose up -d
, remove-d
to keep the console attached And stop it with double ctrl+c ordocker-compose down
if it’s a daemon (-d
)docker run
You could specify the expose port in the command line interface :
docker run -e JVM_XMX=256m \ -v i2phome:/i2p/.i2p \ -v i2ptorrents:/i2psnark \ -p 4444:4444 \ -p 6668:6668 \ -p 7657:7657 \ -p 54321:12345 \ -p 54321:12345/udp \ purplei2p/i2pd
Here for the image
purplei2p/i2pd
—which is the recommended one [2]— you could replace it with other images, likegeti2p/i2p
You could replace port by others you may like, and specify an “external” address, for not exposing a service on the physical network, for exemple :-p 127.0.0.1:75657:7657
dockerfile
Depending of your architecture (typically arm64) or safety level, you may want to build your own image. Relying on the official repository : https://github.com/PurpleI2P/i2pd/tree/openssl/contrib/docker
We could make something like that :
- Dockerfile :
# # Copyright (c) 2017-2022, The PurpleI2P Project # # This file is part of Purple i2pd project and licensed under BSD3 # # See full license text in LICENSE file at top of project tree # FROM alpine:latest LABEL authors="Mikal Villa <mikal@sigterm.no>, Darknet Villain <supervillain@riseup.net>" LABEL maintainer="R4SAS <r4sas@i2pmail.org>" LABEL org.opencontainers.image.source=https://github.com/PurpleI2P/i2pd LABEL org.opencontainers.image.documentation=https://i2pd.readthedocs.io/en/latest/ LABEL org.opencontainers.image.licenses=BSD3 # Expose git branch, tag and URL variables as arguments ARG GIT_BRANCH="openssl" ENV GIT_BRANCH=${GIT_BRANCH} ARG GIT_TAG="" ENV GIT_TAG=${GIT_TAG} ARG REPO_URL="https://github.com/PurpleI2P/i2pd.git" ENV REPO_URL=${REPO_URL} ENV I2PD_HOME="/home/i2pd" ENV DATA_DIR="${I2PD_HOME}/data" ENV DEFAULT_ARGS=" --datadir=$DATA_DIR" RUN mkdir -p "$I2PD_HOME" "$DATA_DIR" \ && adduser -S -h "$I2PD_HOME" i2pd \ && chown -R i2pd:nobody "$I2PD_HOME" # 1. Building binary # Each RUN is a layer, adding the dependencies and building i2pd in one layer takes around 8-900Mb, so to keep the # image under 20mb we need to remove all the build dependencies in the same "RUN" / layer. # # 1. install deps, clone and build. # 2. strip binaries. # 3. Purge all dependencies and other unrelated packages, including build directory. RUN apk update \ && apk --no-cache --virtual build-dependendencies add make gcc g++ libtool zlib-dev boost-dev build-base openssl-dev openssl miniupnpc-dev git \ && mkdir -p /tmp/build \ && cd /tmp/build && git clone -b ${GIT_BRANCH} ${REPO_URL} \ && cd i2pd \ && if [ -n "${GIT_TAG}" ]; then git checkout tags/${GIT_TAG}; fi \ && make -j$(nproc) USE_UPNP=yes \ && cp -R contrib/certificates /i2pd_certificates \ && mkdir -p /usr/local/bin \ && mv i2pd /usr/local/bin \ && cd /usr/local/bin \ && strip i2pd \ && rm -fr /tmp/build && apk --no-cache --purge del build-dependendencies build-base fortify-headers boost-dev zlib-dev openssl-dev \ miniupnpc-dev boost-python3 python3 gdbm boost-unit_test_framework linux-headers boost-prg_exec_monitor \ boost-serialization boost-wave boost-wserialization boost-math boost-graph boost-regex git pcre2 \ libtool g++ gcc # 2. Adding required libraries to run i2pd to ensure it will run. RUN apk --no-cache add boost-filesystem boost-system boost-program_options boost-date_time boost-thread boost-iostreams openssl miniupnpc musl-utils libstdc++ # 3. Copy preconfigured config file and entrypoint COPY i2pd-docker.conf "$DATA_DIR/i2pd.conf" RUN chown i2pd:nobody "$DATA_DIR/i2pd.conf" COPY entrypoint.sh /entrypoint.sh RUN chmod a+x /entrypoint.sh RUN echo "export DATA_DIR=${DATA_DIR}" >> /etc/profile VOLUME "$DATA_DIR" EXPOSE 7070 4444 4447 7656 2827 7654 7650 USER i2pd ENTRYPOINT [ "/entrypoint.sh" ]
#!/bin/sh COMMAND=/usr/local/bin/i2pd # To make ports exposeable # Note: $DATA_DIR is defined in /etc/profile if [ "$1" = "--help" ]; then set -- $COMMAND --help else ln -s /i2pd_certificates "$DATA_DIR"/certificates set -- $COMMAND $DEFAULT_ARGS $@ fi exec "$@"
- docker-compose.yml
version: "3.5" services: i2p: build: context: . dockerfile: Dockerfile volumes: - ./i2pconfig:/i2p/.i2p - ./i2ptorrents:/i2psnark
Ressources :