5

My action endpoints are usually http://localhost:50000/Method/egFunction but when I run the app on a docker container, I am not able to call the api endpoint, I get errors instead. I use docker-compose and here is my code (mongodb also doesn't work yet, I'm trying to get the endpoint working first).

I always used docker-compose up to run the app, but ever since I implemented the restful api's and a database, I might have to change the way to run the command, not sure though. If I do docker-compose up the front-end loads fine but I have no data, and every call to the endpoint gives me an error. I usually load the docker container with this link: http://192.168.99.100:8080

I have this in the docker-compose.yml:

version: '3.4'

services:
  app:
    image: vinnie_app:latest
    links:
      - mongodb
    depends_on:
      - mongodb
  mongodb:
    image: mongo:latest
    container_name: "mongodb"
    ports:
      - 27017:27017

In my docker-compose.override.yml file I have this:

version: '3.4'

services:
  app:
    build: ./app
    environment:
      - ASPNETCORE_ENVIRONMENT=Staging
      - NODE_ENV=staging
    ports:
      - "8080:80"

dockerfile:

FROM microsoft/dotnet:sdk AS build-env
WORKDIR /app

RUN curl -sL https://deb.nodesource.com/setup_10.x |  bash -
RUN apt-get install -y nodejs

# Copy csproj and restore as distinct layers
COPY *.csproj ./
RUN dotnet restore

# Copy everything else and build
COPY . ./
RUN dotnet publish -c Release -o out

# Build runtime image
FROM microsoft/dotnet:aspnetcore-runtime
WORKDIR /app
COPY --from=build-env /app/out .
ENTRYPOINT ["dotnet", "app.dll"]
david benalal
  • 356
  • 5
  • 18
  • 1
    Well since your endpoint uses port 50000 you should probably map that. It would also be helpful if you had the error messages in your post – Shardj Nov 14 '18 at 16:44
  • how do you map port 50000? – david benalal Nov 14 '18 at 16:47
  • The same way you mapped port 8080 – MTCoster Nov 14 '18 at 16:47
  • The same way you mapped 8080 to 80 (why are you using port 8080 not 80?) and 27017 to 27017, just add another line below with 50000:50000. Another thing, how come you're not using http://localhost. What is 192.168.99.100 exactly? – Shardj Nov 14 '18 at 16:48
  • I'm using docker-toolbox, so it has some issues for loading localhost . I'll try adding another line with 50000:50000 and let you know.Thank you – david benalal Nov 14 '18 at 16:50
  • since my docker link is http://192.168.99.100:50000/ and it cant read from the localhost:50000 endpoint, my docker container cant use the restful api's! – david benalal Nov 15 '18 at 00:15

0 Answers0