Glassfish Server with Dockerfile

Asked

Viewed 133 times

0

Good evening, everyone!!

I have the following problem:

I need to upload a container containing the Glassfish server, the image was generated from a Dockerfile, however when running the container containing this image, in the last step, that is, to deploy the application, after some time the container finishes its execution.

Follow the body of Dockerfile

FROM ubuntu:latest
COPY ./glassfish/ /usr/local/
RUN apt-get update && apt-get install -y make git openjdk-8-jdk
ENV JAVA_HOME /usr/lib/jvm/java-8-openjdk-amd64
ENV GLASSFISH_HOME /usr/local/glassfish4/glassfish 
ENV PATH $JAVA_HOME/bin:$GLASSFISH_HOME/bin:$PATH 
RUN mkdir /app
COPY ./mercado/target/mercado.war /app
WORKDIR /app
RUN asadmin start-domain domain1 && \
    asadmin deploy /app/mercado.war


Finally I need the container to be running so that the application does not stop its execution.

I couldn’t identify the error in Dockerfile, but if you can help me right now I appreciate the attention!

1 answer

1


Hello @john.Sousa, so dude, a container is made to die, the problem is not in its last line but in the understanding of the thing, okay? I suggest to study the Docker documentation and mainly how to make it work in Daemon mode. By learning this you already solve your problem. Docker seems difficult, but it is quite simple and will help you much later.

The last line of your script use CMD and point to a Entrypoint file, in this file you run asadmin start-domain domain1 asadmin deploy /app/mercado.war

Another thing, I checked in your script that you copy the Glassfish directory and point the environment variable to glassfish4, I believe you will have a problem there when you manage to run your script correctly.

In addition, there are already images of glassfish 4 (glassfish) or java 8 (openjdk:8-jdk-Alpine) do not need to do all that installation and variable configuration work.

Finally for you to evaluate me very well this answer (but still consider reading the documentation)

You should run this inside the folder where the Dockerfile is docker build -t mercado:1.0 .

This command will build a new container.

docker run --net=host mercado:1.0

This command will run the application and set all ports automatically.

Some cool links to learn the concepts of Docker follow below: https://blog.geekhunter.com.br/docker-na-pratica-como-construir-uma-aplicacao https://www.mundodocker.com.br/o-que-e-docker/

Browser other questions tagged

You are not signed in. Login or sign up in order to post.