Docker and Mango v5.0.2
-
@Jdiaz-co mango starts with ssl on by default for fresh installs. I'd advise generating a mango.properties file with all of your preferred settings and loading that into your image.
Secondly, ensure you've exposed the ports needed to view mango on 8080 or 8443 if you do go with the SSL route...Let me know how you get on
Fox
-
I used your dockerfile to install mango but I get the following error message when starting the container:
Error: Could not find or load main class com.serotonin.m2m2.Main
Caused by: java.lang.ClassNotFoundException: com.serotonin.m2m2.MainDo you know how I can solve this?
-
@Mark I'd ensure all path variables are correct first.
Fox
-
Sorry but my knowledge of Linux is limited.
I put all the files in the right place and then used the docker file to install mango. Have I forgotten something or done it wrong? -
@Mark
If my docker knowledge is correct, I'd replace
ENTRYPOINT exec java -server -cp $MA_CP -Dma.home=$MA_HOME -Djava.library.path=$MA_HOME/overrides/lib:$MA_HOME/lib:/usr/lib/jni/:$PATH com.serotonin.m2m2.Main
with
ENTRYPOINT exec bin/start-mango.sh
Fox
-
@MattFox If I am not wrong, in Mango 5, you must access the web with 8443 (or SSL route) and there is no workaround. I'm using an Mango instance on Windows to try stuff and no way out :"<
-
@tungthanh500 there are ways around this. In Mango 5 the default is to have HTTPS enabled on first start. This also enables HSTS which redirects from the HTTP port to HTTPS. You can change these settings by injecting mango properties into the container or modifying the mango.properties file you are loading.
Take a look at these properties:
# Note: Enabling SSL/TLS also turns on HSTS by default, see the ssl.hsts.enabled setting below ssl.on=true ssl.port=8443 ... # Configure HSTS (HTTP Strict Transport Security) # Enabled by default when ssl.on=true # Sets the Strict-Transport-Security header, web browsers will always connect using HTTPS when they # see this header and they will cache the result for max-age seconds ssl.hsts.enabled=true ssl.hsts.maxAge=31536000 ssl.hsts.includeSubDomains=false
And how to inject them into the container as env variables: https://docs-v5.radixiot.com/configure-mango-properties
Just note that if you change the HSTS settings you will need to clear your browser cache since it will have cached the entry to always use HTTPS already.
-
I have used the file below and now I get the following message:
++ HOME environment variable is /opt/mango
++ mango_paths_home is /opt/mango
+++++ Mango configuration found on
++ mango_script_dir is /opt/mango/bin
++ mango_paths_data is /opt/mango
Mango installation/home directory is /opt/mango
Mango data path is /opt/mango
Starting Mango
Mango started (PID 16)The container returns status "exited"
FROM openjdk:17-ea-17-jdk
COPY free-m2m2-core-5.0.3.zip /tmp
RUN mkdir -p /opt/mango
&& microdnf install -y unzip openssl
&& unzip /tmp/free-m2m2-core-5.0.3.zip -d /opt/mango
&& cd /opt/mangoENV HOME /opt/mango
ENV MA_HOME /opt/mango
ENV MA_CP $MA_HOME/overrides/classes:$MA_HOME/classes:$MA_HOME/overrides/properties:$MA_HOME/overrides/lib/:$MA_HOME/lib/EXPOSE 8443
WORKDIR /opt/mango
ENTRYPOINT exec bin/start-mango.sh $MA_CP -Dma.home=$MA_HOME -Djava.library.path=$MA_HOME/overrides/lib:$MA_HOME/lib:/usr/lib/jni/:$PATH com.serotonin.m2m2.Main -
@Mark
ENTRYPOINT exec bin/start-mango.sh
By itself, you shouldn't need those other parameters. Those environment variables are already set above.
As for why it exited, you'd need to see the output from mango/logs/ma.log.
Alternatively, if it's running then crashing you should be able to view the log in the console by issuing the command
docker run --rm -it --entrypoint /bin/bash <image_name>
That will help you view any remaining output.Fox
-
When I execute your command, a container is created, but without Mango being installed.
Since my knowledge is too limited, I'm going to install mango in a windows environment.
Still, thank you for your efforts!