Docker container exits with code 0 but doesn't give any issue when creating the image

So I have following docker file created to install an internal application on a docker image

FROM centos:7
MAINTAINER Steve De Clercq <steve.declercq@intix.eu>
COPY src/ /home/src/
RUN yum install -y \
   java-1.8.0-openjdk \
   java-1.8.0-openjdk-devel

ENV JAVA_HOME /usr/lib/jvm/java-1.8.0-openjdk/
RUN cd /home/src
RUN adduser imw
RUN   echo "imw soft nofile 65000" >> /etc/security/limits.conf
RUN   echo "imw hard nofile 65000" >> /etc/security/limits.conf
RUN   echo "imw soft nproc 65000" >> /etc/security/limits.conf
RUN   echo "imw hard nproc 65000" >> /etc/security/limits.conf
RUN su imw
RUN java -jar /home/src/intix-solr-2.0.28-installer.jar -d "/home/intix-solr"
RUN sleep 60
RUN mv /home/src/solr.properties /home/intix-solr
RUN echo $(chown -R imw:imw /home/intix-solr)
RUN sleep 60
RUN cd /
RUN /home/intix-solr/bin/intix-solr start
RUN sleep 60
RUN sleep 60
RUN sleep 60
RUN sleep 60
EXPOSE 8180

When I run

docker image -t intix-solr .

I get ne issue and he says succesfully build. Only when I run a container with the image it’s exited with code 0. So that their is no process running in the foreground. But the command “RUN /home/intix-solr/bin/intix-solr start” should start the application already. Does anybody know what I should change or adjust or do I miss something in the unix itself why this won’t start

Your images has no ENTRYPOINT or CMD declaration, thus no instruction to start anything.

The images purpose is to create a point in time snapshot of a base image, your application and its dependencies and typicaly one or more scripts that modify configuration files before they start the main application. You can not “capture” that a process is running while building an image. You can only caputere the effects on the containers filesystem. ENTRYPOINT scripts are responsible to prepare things and start your application. You need to create the entrypoint script yourself and declare it as such in the Dockerfile.

So I need to change?

RUN /home/intix-solr/bin/intix-solr start

to

CMD /home/intix-solr/bin/intix-solr start

Please try. In case you encounter Syntax errors, take a look a the Dockerfile reference.

Additional observations:
– Your Dockerfile is unoptimzied, please take a look at https://www.docker.com/blog/intro-guide-to-dockerfile-best-practices/ for some optimization suggestions.
– You do add the user imw, but there is neither a switch to that user, nor is any process started as the user imw. I am sure this is not what you intended, is it? the command “su imw” does not what you think it would.

May I suggest to spend some time studying the Dockerfile reference? Your Dockerfile looks like you didn’t read it so far.