1

I am running an application in docker setup locally [Installed docker using homebrew in Mac].

I get Could not get any response from postman or Empty reply from server in curl calls.

I tried all the solutions mentioned in docker-machine: Can't access container's web server from host, but none worked for me. I am not sure why I am not able to access the URL.

I am attaching the docker ps and docker-machine env output.

enter image description here

I am also attaching my docker-compose.yml

version: '3.2'
services:
  details:
    image:  localhost:5000/my-details-1
    container_name: details
    #build: ./details
    expose:
      - 9080
  ratings:
    image: localhost:5000/my-ratings-1
    container_name: ratings
    #build: ./ratings
    expose:
      - 9080
  reviews:
    image: localhost:5000/my-reviews-1
    container_name: reviews
    #build: ./reviews/reviews-wlpcfg
    expose:
      - 9080
  restwrapjdbc:
    image: localhost:5000/my-restwrapjdbc
    container_name: restwrapjdbc
    #build: ./RestWrapJDBC
    expose:
      - 8085
  mirest:
    image: localhost:5000/my-mirest
    container_name: mirest
    #build: ./MIRest
    #network_mode: "host"
    expose:
      - 8085
    ports:
      - target: 8085
        published: 8085
        protocol: tcp
        mode: hosts

EDITED:

I forgot to include the url-pattern from web.xml. Including that string to the url worked.

user2761431
  • 925
  • 2
  • 11
  • 26
  • I can't run that `docker-compose.yml` file; it looks like you attached an image instead of the actual contents of the file. Can you delete these two screen shots and replace them? – David Maze Jan 18 '20 at 18:19

1 Answers1

0

You have wrong port maping. Seems like your image exposes port 8080. But you map 8085 to 8085.

Instead:

expose:
      - 8085
ports:
      - target: 8085
        published: 8085
        protocol: tcp
        mode: hosts

write

ports:
      - 8085:8080
GintsGints
  • 807
  • 7
  • 15
  • I get the following errors after your suggested changes when I run `curl http://localhost:8085/ -> HTTP Status 404 – Not Found` `curl http://192.168.99.101:8085/ -> connection refused.` – user2761431 Jan 19 '20 at 20:35
  • ```curl http://localhost:8085/ HTTP Status 404``` So that means your docker responds now! You have to add correct path. – GintsGints Jan 19 '20 at 21:06
  • Also you can check how your app responds inside container. Just execute: ```docker exec -it mirest /bin/bash``` And now you can check curl to localhost inside container. – GintsGints Jan 19 '20 at 21:08
  • Still status 404-Not found. – user2761431 Jan 19 '20 at 21:54
  • Did you update your path? How your REST api responds within development environment? – GintsGints Jan 19 '20 at 22:08
  • Also make sure you specify your application does not check request type to be JSON. – GintsGints Jan 19 '20 at 23:45
  • I figured that the `web.xml` had the `url-pattern` included. Post including, it worked. Thanks for your help! – user2761431 Jan 20 '20 at 12:40