Docker Community Forums

Share and learn in the Docker community.

Using docker compose with a .net core app

So I am trying to dockerize the development environment for a .net core app

I have an app that exposes some endpoints and uses redis. I want the entrypoint for this app to be the bash

I managed to connect my container to redis container through docker-compose, however I can not access the endpoints despite the fact that I already exposed the endpoints … here are the files

FROM mcr.microsoft.com/dotnet/core/sdk:3.1 AS build-env

COPY ./ ./
WORKDIR /var/code

ENTRYPOINT "bash"

docker-compose

version: '2.4'

services:  
  app:
    tty: true
    stdin_open: true
    container_name: transactions
    depends_on:
      - redis
    build:
      context: .
      dockerfile: Dockerfile.base
    ports:
      - '6001:6001'
      - '6000:6000'
    volumes:
      - .:/var/code:rw

  redis:
    image: redis
    ports:
      - "6379:6379"

then I run
docker-compose up -d --build && docker exec -it ${PWD##*/} bash

I enter the bash, I run the server and it tells me

Now listening on: https://localhost:6001
Now listening on: http://localhost:6000

I tried accessing the container through localhost, IP address of the container but nothing worked

Build and deploy manually
Navigate to the project folder at dotnet-docker/samples/aspnetapp/aspnetapp.
Run the dotnet publish command: .NET Core CLI Copy. dotnet publish -c Release -o published. The command arguments: …
Run the app. Windows: .NET Core CLI Copy. dotnet published\aspnetapp.dll.