Skip to content
This repository has been archived by the owner on Aug 23, 2020. It is now read-only.

Commit

Permalink
Removed DOCKER_IRI_NEIGHBOR_FILE and hardcoded --neighbors option. Al…
Browse files Browse the repository at this point in the history
…so added attachToTangle to the list of APIs disabled by default. Updated docs
  • Loading branch information
geminoz committed May 10, 2018
1 parent aef41a6 commit 9fc302b
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 14 deletions.
24 changes: 17 additions & 7 deletions DOCKER.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,17 @@
## DOCKER and IRI
## Quickstart

1. Run the official iotaledger/iri container, passing the mandatory -p option
```docker run iotaledger/iri:v1.4.2.4 -p 14265```

This will get your a running IRI with its API listening on port 14265, no neighbours and an empty database. The IRI Docker container by default expects data at /iri/data. Use the `-v` option of the `docker run` command to mount volumes so to have persistent data. You can also pass more command line options to the docker run command and those will be passed to IRI.

If you want to use a iri.ini file with the docker container, supposing it's stored under /path/to/conf/iri.ini on your docker host, then pass `-v /path/to/conf:/iri/conf` and add -c /iri/conf/iri.ini as docker run arguments. So for example the `docker run` command above would become:

```docker run -v /path/to/conf:/iri/conf -v /path/to/data:/iri/data iotaledger/iri:v1.4.2.4 -p 14265 -c /iri/conf/iri.ini```

Please refer to the IRI documentation for further command line options and iri.ini options.

## DOCKER and IRI in depth

The Dockerfile included in this repo builds a working IRI docker container whilst trying to stay the least opinionated as possible. This allows system administrators the option to deploy and configure IRI based on their own individual circumstances and needs.

Expand All @@ -15,18 +28,16 @@ JAVA_OPTIONS: these are the java options to pass right after the java command. I
JAVA_MIN_MEMORY: the value of -Xms option. Defaults to 2G
JAVA_MAX_MEMORY: the value of -Xmx option. Defaults to 4G
DOCKER_IRI_JAR_PATH: defaults to /iri/target/iri*.jar as pushed by the Dockerfile. This is useful if custom IRI binaries want to be executed and the default path needs to be overridden
DOCKER_IRI_REMOTE_LIMIT_API: defaults to "interruptAttachToTangle, addNeighbors, removeNeighbors, getNeighbors"
DOCKER_IRI_NEIGHBOR_FILE: defaults to an empty value. If set, the entrypoint looks for such file and adds each line as IRI neighbours. Commented lines will be skipped
DOCKER_IRI_REMOTE_LIMIT_API: defaults to "interruptAttachToTangle, attachToTangle, addNeighbors, removeNeighbors, getNeighbors"
DOCKER_IRI_MONITORING_API_PORT_ENABLE: defaults to 0. If set to 1, a socat on port 14266 directed to 127.0.0.1:DOCKER_IRI_MONITORING_API_PORT_DESTINATION will be open in order to allow all API calls regardless of the DOCKER_IRI_REMOTE_LIMIT_API setting. This is useful to give access to restricted API calls to local tools and still denying access to restricted API calls to the internet. It is highly recommended to use this option together with docker networks (docker run --net).

The container entry point is a shell script that performs few additional steps before launching IRI:
- verifies if DOCKER_IRI_MONITORING_API_PORT_ENABLE is set to 1
- verifies if DOCKER_IRI_NEIGHBOR_FILE is set
- launches IRI with all parameters passed as desired

It is important to note that other than --neighbors (via the env var DOCKER_IRI_NEIGHBOR_FILE), --remote and --remote-limit-api "$DOCKER_IRI_REMOTE_LIMIT_API", neither the entrypoint nor the Dockerfile are aware of any IRI configuration option. This is to not tie the Dockerfile and its container to a specific set of IRI options. Instead, this contain still allows the use of an INI file or command line options. Please refer to the IRI documentation to learn what are the allowed options at command line and via the INI file.
It is important to note that other than --remote and --remote-limit-api "$DOCKER_IRI_REMOTE_LIMIT_API", neither the entrypoint nor the Dockerfile are aware of any IRI configuration option. This is to not tie the Dockerfile and its container to a specific set of IRI options. Instead, this contain still allows the use of an INI file or command line options. Please refer to the IRI documentation to learn what are the allowed options at command line and via the INI file.

At the time of writing, IRI requires -p to be passed either via INI or via command line. The entrypoint of this docker container does not do that for you.
**At the time of writing, IRI requires -p to be passed either via INI or via command line. The entrypoint of this docker container does not do that for you.**

Here is a systemd unit example you can use with this Docker container. This is just an example and customisation is possible and recommended. In this example the docker network iri must be created and the paths /mnt/iri/conf and /mnt/iri/data are used on the docker host to serve respectively the neighbors file and the data directory. No INI files are used in this example, instead options are passed via command line options, such as --testnet and --zmq-enabled.

Expand All @@ -48,7 +59,6 @@ ExecStart=/usr/bin/docker run \
-p 14265:14265 \
-p 15600:145600/udp \
-p 14600:14600/udp \
-e "DOCKER_IRI_NEIGHBOR_FILE=/iri/conf/neighbors" \
iotaledger/iri:v1.4.2.4 \
-p 14265 \
--zmq-enabled \
Expand Down
3 changes: 1 addition & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,7 @@ ENV JAVA_MAX_MEMORY 4G

# Additional custom variables. See DOCKER.md for details
ENV DOCKER_IRI_JAR_PATH "/iri/target/iri*.jar"
ENV DOCKER_IRI_REMOTE_LIMIT_API "interruptAttachToTangle, addNeighbors, removeNeighbors, getNeighbors"
ENV DOCKER_IRI_NEIGHBOR_FILE "/iri/conf/neighbors"
ENV DOCKER_IRI_REMOTE_LIMIT_API "interruptAttachToTangle, attachToTangle, addNeighbors, removeNeighbors, getNeighbors"

# Setting this to 1 will have socat exposing 14266 and pointing it on
# localhost. See /entrypoint.sh
Expand Down
5 changes: 0 additions & 5 deletions docker/entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,11 @@ if [ "${DOCKER_IRI_MONITORING_API_PORT_ENABLE}" == "1" ]; then
nohup socat -lm TCP-LISTEN:14266,fork TCP:127.0.0.1:${DOCKER_IRI_MONITORING_API_PORT_DESTINATION} &
fi

for neighbor in $(grep -v \# $DOCKER_IRI_NEIGHBOR_FILE); do
DOCKER_IRI_NEIGHBORS+=" $neighbor"
done

exec java \
$JAVA_OPTIONS \
-Xms$JAVA_MIN_MEMORY \
-Xmx$JAVA_MAX_MEMORY \
-Djava.net.preferIPv4Stack=true \
-jar $DOCKER_IRI_JAR_PATH \
--remote --remote-limit-api "$DOCKER_IRI_REMOTE_LIMIT_API" \
--neighbors "$DOCKER_IRI_NEIGHBORS" \
"$@"

0 comments on commit 9fc302b

Please sign in to comment.