Running two docker container on same Network# Spring boot microservices # Docker # Docker Images #Docker Container

#consumer

class TestController{

@Getmapping("data")

public String getData(){

RestTemplate  t=new RestTemplate();

t.getforObject( "http://consumer:8080/getdata",String.class);

}

}


FROM openjdk:8

EXPOSE 8080

ADD target/producer.jar producer.jar

ENTRYPOINT ["java","-jar", "producer.jar"]





#producer

class TestController

{

@Getmapping("getdata")

public String getData(){

return "This reponse comming from producer"

}

}


FROM openjdk:8

EXPOSE 7000

ADD target/consumer.jar consumer.jar

ENTRYPOINT ["java","-jar", "consumer.jar"]


first craete network :  


docker   create --network driver=bridge mynetwork (need correction from book)


docker build -f  Dockerfile -t consumer (any name its just a tag name) .

docker run -p 81:8080 --name=producer --network=mynetwork producer


docker build -f  Dockerfile -t producer (any name its just a tag name) .

docker run -p 82:7000 --name=consumer --network=mynetwork consumer


command to insepct network

docker inspect network mynetwork (mynetwork is a network name)




Comments

Popular posts from this blog

Filter In Javafx

Kotlin with StandAlone Complier