I’m playing around with Docker and trying to learn it. My goal is to create a micro-service setup with multiple .net core API’s and an Angular frontend.
I’ve started with 1 API.
I made a dockerfile and a docker-compose file.
my dockerfile:
#See https://aka.ms/customizecontainer to learn how to customize your debug container and how Visual Studio uses this Dockerfile to build your images for faster debugging.
FROM mcr.microsoft.com/dotnet/aspnet:8.0 AS base
USER app
WORKDIR /app
EXPOSE 8080
EXPOSE 8081
FROM mcr.microsoft.com/dotnet/sdk:8.0 AS build
ARG BUILD_CONFIGURATION=Release
WORKDIR /src
COPY ["Api/Api.csproj", "Api/"]
RUN dotnet restore "./Api/./Api.csproj"
COPY . .
WORKDIR "/src/Api"
RUN dotnet build "./Api.csproj" -c $BUILD_CONFIGURATION -o /app/build
FROM build AS publish
ARG BUILD_CONFIGURATION=Release
RUN dotnet publish "./Api.csproj" -c $BUILD_CONFIGURATION -o /app/publish /p:UseAppHost=false
FROM base AS final
WORKDIR /app
COPY --from=publish /app/publish .
ENTRYPOINT ["dotnet", "Api.dll"]
My docker-compose file:
version: '3.4'
services:
todo.api:
image: todoapi
container_name: todo.api
build:
context: ./TestProject.Service.Todo
dockerfile: Api/Dockerfile
ports:
- "5000:5000"
- "5001:5001"
Whenever I start the docker-compose it runs and creates a container without issue but when I try to access the “WeatherForecast” api method that is added by default in the API project I can’t access it.
When I run Visual Studio with the Docker option it also creates the container without issue and I can access the “WeatherForecast” api method without issues.
I currently can’t see what is wrong with my current basic setup, could someone help me out with spotting the issue?
I googled the issue but didn’t seem to find a working solution to my issue.
John Jameson is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.