I have build my application using the docker file on google gcp. I am trying to run my web application build/run on tomcat.
from ubuntu
COPY /mnt/opt/apache-tomcat-9.0.5/ /mnt/opt/apache-tomcat-9.0.5/
RUN apt update
COPY cronjob /etc/cron.d/cronjob
RUN chmod 0644 /etc/cron.d/cronjob
RUN crontab /etc/cron.d/cronjob
ENV CATALINA_HOME /mnt/opt/apache-tomcat-9.0.5
ENV PATH $CATALINA_HOME/bin:$PATH
ENV PATH /mnt/opt/java/jdk-10.0.1/bin:$PATH
ENV PORT 80
ENV HOST 0.0.0.0
EXPOSE 80 443
CMD /mnt/opt/apache-tomcat-9.0.5/bin/catalina.sh run
#ENTRYPOINT ["/mnt/opt/apache-tomcat-9.0.5/bin/catalina.sh", "run"]
Using the following approach to deploy on google cloud run.
docker tag miniimagesvideos gcr.io/serious-bearing-358305/miniimagesvideos
docker push gcr.io/serious-bearing-358305/miniimagesvideos
gcloud run deploy –image=gcr.io/serious-bearing-358305/miniimagesvideos –port=80 –region=asia-southeast2 –allow-unauthenticated platform=managed –command=/mnt/opt/apache-tomcat-9.0.5/bin/catalina.sh
I keep getting error mentioned in the subject line
- I looked at the logs and there is no additional information.
- As per the troubleshooting steps mentioned by Google document all the requirement seems to be ok. I am able to run my application successfully on Google cloud VM. The application is build on 64 bit.
- I have tried multiple options like using the –command, port, host parameter while trying to deploy.
- I have tried to use CMD, instead of ENTRYPOINT in dockerfile. However, the result remains the same. I have tried to invoke tomcat using startup.sh vs Catalina.sh. But the outcome remains the same.
- I have tried to deploy the application from GUI, but the same error comes up.
It seem container shuts down immediately while trying to deploy on Google Cloud run. Whereas, there is no issue while trying to run docker container on a Google VM.
Is there any additional configuration required for Google cloud run. Why tomcat is not able to run on Google cloud run?
2
Answers
The following combination worked on Google Cloud run.
Please note i was required to implement some additional steps for my app to migrate from 9.0.75 to 10.1.8. These are trivial changes to migrate from tomcat 9.x to 10.x.
SSL Connector needs an explicit tag for SSLHostconfig
In the context.xml the following needs to be added
Conclusion After multiple troubleshooting, i could reach to the following conclusion
Google cloud run execute Catalina.sh in a manner that the tomcat is running the background. Log indicate "Tomcat Started" and then there is another log of "container exited".
However, for 10.X version tomcat is kicked off as a foreground process.
This could be due to bug in
gcloud
. It has been fixed in the latest release. Try updating to latest version by using below commandIf this still doesn’t work, You could use the following flag
--format=export
in the commandgcloud run services describe --format=export <SERVICE-NAME>
which would return the
YAML
file containing the configuration of theCloud Run
service. On this file you would have to change manually the fields “containerPort” and the “port” variable under “tcpSocket” in “startupProbe”.Once you have the YAML properly configured you can use the following command to update the configuration of the service, effectively changing the port.
gcloud run services replace <yaml-file>