Running OTmonitor in dockerDocker is an open platform for developing, shipping, and running applications. It is assumed that anyone interested in running OTmonitor in docker is already familiar with the ecosystem and has a working docker setup. General useThe general command to start an OTmonitor docker container will look something like: docker run -d \ --user $(id -u):$(id -g) \ -p 2380:8080 \ -e TZ=Europe/Amsterdam \ -v $HOME/.config/otmonitor:/data \ -v $HOME/otlogs:/log \ hvxl/otmonitor:stableNote: Make sure the specified directories exist before starting the container. If not, they will be created by the docker daemon, which generally runs as root. As a result, the user will not have sufficient permissions to create files in these directories.
Explanation of the used arguments
Fabricated/anticipated questionsThis section was created along with the rest of the description. So there were no frequently asked questions yet. But I thought it might be useful to have a "FAQ" anyway.
How do I create the initial otmonitor.conf file?With OTmonitor docker images from other sources it used to be necessary to provide a minimal otmonitor.conf file to start the web server. The hvxl/otmonitor image starts the web server by default. So you can just access the web pages by pointing your browser to the port you specified in the -p option. Then go to the "Configure" link and set things up as you like.Can I just map the otmonitor.conf file instead of a whole directory?This used to be the advice for other OTmonitor docker images. It is possible, but there are a few pitfalls with that technique:
Do I still have to specify the -p option if I just want to use port 8080?Yes. Docker doesn't automatically expose the web server port to the outside world. To use port 8080, specify: -p 8080:8080.I configured a different web server port, but it reverts to 8080 after a restart.By default, OTmonitor is executed with a command line option to start the web server on port 8080. This overrides the setting in the configuration file. The default command line option is discarded if you append any arguments to the docker run command. You could use "-l", for example.How can I use my existing otmonitorrc configuration file when following the advice to map a configuration directory?You can append arguments to the docker run command that will be passed to OTmonitor. To use a configuration file called otmonitorrc, add "-f /data/otmonitorrc". You still have to specify the directory as /data, as that is the internal path that is mapped to your external configuration directory. You may also have to change the port mapping if your configuration file uses a different port for the web server:docker run --user $(id -u):$(id -g) -dp 4280:4280 -e TZ=Europe/Amsterdam \ -v $HOME/otlogs:/log -v $HOME/.config/otmonitor:/data \ hvxl/otmonitor:stable -f /data/otmonitorrc I need to collect a log file. What configuration should I use?In the Logging configuration tab, specify "/log" as the log file directory. Use whatever name pattern suits your needs. Don't include any directories in the name pattern. Then check the Logfile box. Now the logs will be created in the directory you mapped to /log in the docker run command.I collected a log file in /log, but I forgot to map the directory in the docker run command. How do I get the file?You can use the "docker cp" command to copy the log file out of the container:docker cp $(docker ps -qf ancestor=hvxl/otmonitor:stable):/log/otlog.txt . My OTGW has a name on the network, but I cannot connect to it using its name in otmonitor.If you run your docker daemon on the same machine that provides the name service for your local network (e.g. using dnsmasq), your /etc/resolv.conf probably points to localhost (127.0.0.1 or ::1). Docker picks up this file for use by your containers. But inside a container, localhost is not the same thing as it is on the host. To fix this, add the --dns IP-address option to the docker run command. Specify the external IP address of your machine.How can I run the image, but start a shell instead of the otmonitor program?The image specifies the otmonitor command as its entry point. To override that, you have to use the --entrypoint option. When running a shell, you will also want to run interactively:docker run -it --entrypoint=sh hvxl/otmonitor How can I install a web page that I have modified in the image?You can create your own image based on the hvxl/otmonitor image by creating a Dockerfile:FROM hvxl/otmonitor RUN mkdir -p /usr/local/bin/html COPY status.html.tmpl footer.inc /usr/local/bin/html/.Then build the image using: docker build -t otmon-priv .Alternatively, run the image as root, make the necessary changes, and create a new image from the modified container: docker run -d hvxl/otmonitor docker exec $(docker ps -ql) mkdir /usr/local/bin/html docker cp status.html.tmpl $(docker ps -ql):/usr/local/bin/html docker cp footer.inc $(docker ps -ql):/usr/local/bin/html docker commit $(docker ps -ql) otmon-priv |