noobTheSecond
noobTheSecond

Reputation: 3

Containarize spring booot microservices

For a project i'm trying to put my microservices inside a container. Right now I can succesfully put a jar file inside a docker container and run it. I know how docker images and containers work. But Im very new on microservices, a friend of me asked to put his spring boot microservices in a docker environment. Right now this is my plan. Put every microservice inside 1 container , manage them with docker compose so that you can run and config them at the same time. And maybe later put some high availibility in it with docker compose scale or try something out with Docker swarm.

My question now is how do you put one service inside a container. Do you create a jar /war file from a service put that inside a container with the expose port you are working with inside your service ?

For my testjar file (a simple hello world i found online) i used this dockerfile

FROM openjdk:8
ADD /jarfiles/test.jar test.jar
EXPOSE 8080
ENTRYPOINT ["java", "-jar" , "test.jar"]

Upvotes: 0

Views: 164

Answers (1)

ABHAY JOHRI
ABHAY JOHRI

Reputation: 2156

You need to convert your spring boot application into docker image. Conversion of boot application can be converted using docker maven plugin or you can use docker command for this.

Using docker you need dockerfile that have the steps for creating docker image.

Once your image is ready you can run that docker image on docker engine, hence image after run will be a docker container. That is basically the virtualization.

There set of docker commands for running/creating docker images.

Install docker engine and start docker engine using

service docker start

And then use all docker commands

Upvotes: 0

Related Questions