I have a .NET 6 console app with docker-compose. The compose file is:
version: '3.4'
services:
rms:
image: ${DOCKER_REGISTRY-}rms
build:
context: .
dockerfile: rms/Dockerfile
restart: always
environment:
ENV1: a
ENV2: b
And I have an API that runs on AWS like this: https://rms.xxx.com
If I request this API with HttpClient
inside the console app with docker-compose, I get an error
No route to host (rms.xxx.com:443)
I have tried many things to solve the problem but none worked.
Here is the Dockerfile:
FROM mcr.microsoft.com/dotnet/runtime:6.0 AS base
WORKDIR /app
FROM mcr.microsoft.com/dotnet/sdk:6.0 AS build
WORKDIR /src
COPY ["xxx.RMS.ApplicationRunner/xxx.RMS.ApplicationRunner.csproj", "xxx.RMS.ApplicationRunner/"]
COPY ["xxx.RMS.Library/xxx.RMS.Library.csproj", "xxx.RMS.Library/"]
COPY ["xxx.RMS.Repository/xxx.RMS.Repository.csproj", "xxx.RMS.Repository/"]
COPY ["xxx.RMS.Infrastructure/xxx.RMS.Infrastructure.csproj", "xxx.RMS.Infrastructure/"]
COPY ["xxx.RMS.Common.Core/xxx.RMS.Common.Core.csproj", "xxx.RMS.Common.Core/"]
RUN dotnet restore "xxx.RMS.ApplicationRunner/xxx.RMS.ApplicationRunner.csproj"
COPY . .
WORKDIR "/src/xxx.RMS.ApplicationRunner"
RUN dotnet build "xxx.RMS.ApplicationRunner.csproj" -c Release -o /app/build
FROM build AS publish
RUN dotnet publish "xxx.RMS.ApplicationRunner.csproj" -c Release -o /app/publish /p:UseAppHost=false
FROM base AS final
WORKDIR /app
COPY --from=publish /app/publish .
ENTRYPOINT ["dotnet", "xxx.RMS.ApplicationRunner.dll"]
How can I solve the problem? How to communicate between the console app with docker-compose and a random API?
Note: I couldn't insert API information to this compose file like adding another service.