I have a handful of docker images that work fine. Except for the ports that are always 5000 (the default on asp.net core), everything works. I have tried multiple methods to get around this, but I am out of ideas now.
The containers are running on Debian 9- Hosted on Linode
Ran my build with
docker-compose -f docker-compose.yml up
My docker-compose.yml
#Api Service
API:
build:
context: .
#Use the DockerFile in that Directory
dockerfile: Dockerfile
#This Service Depends on the database service specifed above
depends_on:
- database
#Map port 8888 in the docker container to port 80 in the Api
ports:
- "5000:80"
restart: always
#Specify Environment Variables for the Api Service
environment:
- DBHOST=database
- ASPNETCORE_ENVIRONMENT=Production
Content for DockerFile
FROM mcr.microsoft.com/dotnet/aspnet:5.0 AS base
WORKDIR /app
EXPOSE 80/tcp
FROM mcr.microsoft.com/dotnet/sdk:5.0 AS build
WORKDIR /src
COPY ["TestApi.csproj", "./"]
RUN dotnet restore "TestApi.csproj"
COPY . .
WORKDIR "/src/."
RUN dotnet build "TestApi.csproj" -c Release -o /app/build
FROM build AS publish
RUN dotnet publish "TestApi.csproj" -c Release -o /app/publish
FROM base AS final
WORKDIR /app
COPY --from=publish /app/publish .
ENTRYPOINT ["dotnet", "TestApi.dll"]
File content docker-compose.debug.yml
version: '3.4'
services:
testapi:
image: testapi
build:
context: .
dockerfile: ./Dockerfile
ports:
- 80
- 5000
environment:
- ASPNETCORE_ENVIRONMENT=Production
- ASPNETCORE_URLS=http://+:80
volumes:
- ~/.aspnet/https:/https:ro