Running Springboot app from docker-compose file

I’ve created an image for my springboot app and added the following service to the docker-compose.yml file which I’ve included in my project:

  temporal-client:
    container_name: our-client
    image: springio/gs-spring-boot-docker
    ports:
      - 8091:8091

When I run the file (docker-compose up), the temporal container always dies, and my app cannot make the connection to the server. When I remove my service above from the docker-compose.yml file, temporal runs.

Additionally, here is some code from my application where I build a temporal service:

    WorkflowServiceStubsOptions options =
            WorkflowServiceStubsOptions.newBuilder()
                    .setTarget("temporal:7233")
                    .build();

    service = WorkflowServiceStubs.newInstance(options);

Not sure if that’ll help, but I’m putting in just in case.

How can I fix this? Any help is greatly appreciated. Thanks

WorkflowServiceStubsOptions look ok (setting the target to “temporal:7233”).
One thing you might be missing is depends_on to wait for temporal service to start before staring up your app, for example:

temporal-client:
    container_name: our-client
    depends_on:
      - temporal
    image: springio/gs-spring-boot-docker:latest
    ports:
      - 8095:8095

Another thing to look into is your the logs when you run docker compose up to see why your app startup is failing. One thing that can happen is that you compiled your app with one java version and then use a wrong version base image in Dockerfile, maybe check for that.
Here is simple Dockerfile that worked locally:

FROM openjdk:11-slim
MAINTAINER temporal.io
COPY target/dockerdemo-1.0.jar dockerdemo-1.0.jar
ENTRYPOINT ["java","-jar","/dockerdemo-1.0.jar"]

with

java --version
openjdk 11.0.11 2021-04-20

Image built with docker build -t mydemos/dockerdemo .