How to deploy a java app to Docker?

+1 vote

I am doing POC on deploying these Microservices to Docker. I made a simple application with maven, Java 8 (not OpenJdk) and jar file is ready to be deployed but I stuck with the exact steps on how to deploy and run/test the application on Docker container.

I've already downloaded Docker on mac and went over this documentation but I feel like there are some steps missing in the middle and I got confused.

I appericiate your help.

Thank you!

Aug 2, 2018 in Docker by Atul
• 10,240 points
32 views

1 answer to this question.

0 votes

If you are having JAR file, the quickest way to try it out in docker is to create a Dockerfile which uses the official OpenJDK base image, copies in your JAR and configures Docker to run it when the container starts:

FROM openjdk:7
COPY my.jar /my.jar
CMD ["java", "-jar", "/my.jar"]

With that Dockerfile in the same location as your JAR file run:

docker build -t my-app .

Which will create the image, and then to run the app in a container:

docker run my-app

I hope it will resolve your query.

answered Aug 2, 2018 by Damon Salvatore
• 5,510 points

Related Questions In Docker

+4 votes
4 answers

How To Access a Service on Host From a Docker Container?

Adding to kalgi's answer, You can also ...READ MORE

answered Oct 16, 2018 in Docker by lina
• 8,100 points

edited Oct 16, 2018 by lina 3,820 views
0 votes
1 answer

How to run a docker command from inside the container?

You must have come across the /var/run/docker.sock file, ...READ MORE

answered Jun 28, 2018 in Docker by Sophie may
• 9,530 points
304 views
0 votes
2 answers
0 votes
1 answer
0 votes
1 answer

Deploy Docker Containers from Docker Cloud

To solve this problem, I followed advice ...READ MORE

answered Sep 3, 2018 in AWS by Priyaj
• 56,520 points
135 views
0 votes
1 answer

How do I copy a file from docker container to host?

Here is a way which you can ...READ MORE

answered Aug 27, 2018 in Docker by Damon Salvatore
• 5,510 points
1,971 views
0 votes
1 answer