skip to Main Content

when i run the command

docker-compose up –build

in cmd it log Tomcat started on port(s): 8089 (http) with context path ‘/*****

but when i try to connect to some API in postman it gives me Error: socket hang up

Here is my docker-compose :

version: '3.3'
services:
  web:
     build:
        dockerfile: Dockerfile
     image: 2021.jar
     image: tomcat:9.0-jdk8
     volumes:
      - ./ROOT:/usr/local/tomcat/webapps/ROOT
      - ./repository:/usr/local/tomcat/webapps/ROOT/repository
     ports:
      - '8089:8080'
     environment:
      - JAVA_OPTS= -Ddb.host=localhost -Ddb.catalog=gohybridit_dev -Ddb.port=5432 -Ddb.username=postgres -Ddb.password=123

and this my Dockerfile

FROM openjdk:8-jdk-alpine
ARG JAR_FILE=target/*.jar
COPY ${JAR_FILE} 2021.jar
ENTRYPOINT ["java","-jar","2021.jar"]

2

Answers


  1. Chosen as BEST ANSWER

    I come with this command and solved my problem

    docker run -d -p portNum:portNum --restart always XXXXX.jar
    

  2. I am guessing you are setting port 8089 in your application properties. If you are, either:

    a) update the docker-compose to say '8089:8089' instead.

    b) update application properties to set the port to 8080 (or remove it altogether as this is the default)

    Basically, those ports are <outside container>:<inside container>. I personally would match all the ports to 8089 per the first option to reduce confusion.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search