I have a dockerfile that looks like this:
FROM mcr.microsoft.com/dotnet/core/aspnet:2.2-alpine AS base
ENV ASPNETCORE_URLS=http://+:50777
EXPOSE 50777
FROM mcr.microsoft.com/dotnet/core/sdk:2.2-alpine AS build-env
COPY . /app
RUN dotnet restore
WORKDIR /app
ARG ASPNETCORE_ENVIRONMENT="Production"
ARG DATABASE_CONN_STRING="Server=tcp:mssqldb,1433; Database=test; User=sa; Password=test123;"
ARG ALLOWED_CORS=http://localhost:3000
ARG DOTNET_RUNNING_IN_CONTAINER=true
WORKDIR /app/backend
RUN dotnet publish -c Release -o /app/out
FROM base as final
WORKDIR /app
COPY --from=build-env /app/out ./out
WORKDIR /app/out
ENTRYPOINT ["dotnet", "test.project.dll"]
The project uses a database container and a backend container, exposing port 50777 for interaction with the APIs.
Given the dockerfile above, the build completes successfully, and the app is running in the container, but I can't reach the backend APIs.
Now I understood that ENV is used when the container is run, and the ARG are used during building, so what could be the reason why I cannot connect to it?
[EDIT]
Docker run command:
docker run -d --name api -p 50777:50777 -it test-image tail -f /dev/null