Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Docker CMD exit 0

I’m trying to make a container that on start runs a maven command if a folder do not exists; but always after run the command I get a message "Neomind_dev exited with code 0".

Is there a way by dockerfile or docker-compose to run a script with return after the container start and do not let the container exit?

the dockerfile:

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

FROM tomcat
ENV MAVEN_VERSION "3.8.4"
ENV MAVEN_HOME "/usr/share/maven"
ENV PATH "${MAVEN_HOME}/bin:${PATH}"

# Install tools
RUN apt-get update && \
    wget -O /tmp/apache-maven-${MAVEN_VERSION}.zip http://ftp.unicamp.br/pub/apache/maven/maven-3/${MAVEN_VERSION}/binaries/apache-maven-${MAVEN_VERSION}-bin.zip && \
    unzip /tmp/apache-maven-${MAVEN_VERSION}.zip -d /usr/share && \
    mv /usr/share/apache-maven-${MAVEN_VERSION} ${MAVEN_HOME} && \
    rm -rf /tmp

COPY settings.xml ${MAVEN_HOME}/conf/settings.xml
COPY ./build.sh /

WORKDIR /
CMD sh build.sh

the script

if [ ! "$(ls /usr/local/fusion)" ]; then 
cd /usr/local 
mvn archetype:generate -B -Pneomind-archetype -DarchetypeGroupId=com.neomind.archetype -DarchetypeArtifactId=fusion-client-archetype -DarchetypeVersion=1.1 -DtenantId=Neomind-dev -DfusionVersion=3.15.5 
fi

>Solution :

  1. Container exits because your scripts run without error and ends the process.
  2. To keep the process/container running you can add a command at last of docker file for tomcat to be running continuously : CMD ["catalina.sh" "run"].
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading