Can get my docker container to run in VS2017 in debug, but not PS cmd line

I’m new to Docker so my question may be stupid.

It took me awhile to get my .Net Core 2.2.4 project to work in Docker for Windows, had to rewrite lots of code in Program.cs to pin my SSL certificate to the project. But I tested my localhost.pfx and my domain.pfx and they both work in development. That took awhile to figure out. Now I’m trying to deploy to my production server.

Working with my Linux Production Server
Uploaded my image to Docker Hub, pulled it into my new Unbuntu Bionic Beaver server and it just fails to load and run. The verbose I get seems to be the same as the verbose I get in Docker for Windows on my workstation.

Back to Docker for Windows; maybe I missed something
So I can build my project and it will run in docker for windows using VS2017 V15.0.11. But when I use my compose file, it bombs after creating the project when it goes to test connections. When I try and use the command line “docker run -t -d -p 80:80 -p 5000:5000 -p 5001:443 imageName”, it loads, doesn’t seem to error but I can’t access it in my browser. Maybe I have the ports wrong. I didn’t know how to recreate those ports on the command line.

On the one that works in Docker for Windows when VS2017 loads the debug versiont

Docker PS
“80/tcp, 5000-5001/tcp, 0.0.0.0:5001->443/tcp”
are the ports.

My docker file; I thought perhaps when I ran the container on my Linux server I had to sudo inside the companion containers, thus the commented out lines

FROM microsoft/dotnet:2.2-aspnetcore-runtime AS base
WORKDIR /app
EXPOSE 80 443
EXPOSE 5000 5001

FROM microsoft/dotnet:2.2-sdk AS build
WORKDIR /src
COPY [“jkirkerxAngular/jkirkerxAngular.csproj”, “jkirkerxAngular/”]
RUN dotnet restore “jkirkerxAngular/jkirkerxAngular.csproj”
COPY . .
WORKDIR “/src/jkirkerxAngular”
RUN dotnet build “jkirkerxAngular.csproj” -c Release -o /app

FROM build AS publish
RUN dotnet publish “jkirkerxAngular.csproj” -c Release -o /app

FROM base AS final
WORKDIR /app
COPY --from=publish /app .
ENTRYPOINT [“dotnet”, “jkirkerxAngular.dll”]

FROM alpine:latest
#RUN apt-get install sudo
#COPY sudoers /etc/
#RUN apk update && apk add sudo && adduser -u 1000 -G wheel -D alpine && rm -rf /var/cache/apk/*
#USER alpine

RUN apk update && apk add ca-certificates && rm -rf /var/cache/apk/*
COPY jkirkerxAngular/jkirkerx.pfx /usr/local/share/ca-certificates/jkirkerx.pfx
COPY jkirkerxAngular/localhost.pfx /usr/local/share/ca-certificates/localhost.pfx
RUN update-ca-certificates

So to figure this out, I figured I should be able to command line my image to run it in a container in my Docker for Windows.

When I use my compose file, the container stops here.
Verbose Output with compose entrypoint: [“sh”, “-c”, “sleep 5000”]

Attaching to jkirkerxAngular
compose.cli.verbose_proxy.proxy_callable: docker events ← (filters={‘label’: [‘com.docker.compose.project=jkirkerxangular’, ‘com.docker.compose.oneoff=False’]}, decode=True)
urllib3.connectionpool._make_request: http://localhost:None “GET /v1.38/events?filters=%7B%22label%22%3A+%5B%22com.docker.compose.project%3Djkirkerxangular%22%2C+%22com.docker.compose.oneoff%3DFalse%22%5D%7D HTTP/1.1” 200 None
compose.cli.verbose_proxy.proxy_callable: docker events → <docker.types.daemon.CancellableStream object at 0x000001C31A463B00>

Side Note:
my .Net Core project is Angular wrapped in .Net Core 2.2.4.
I figured this container testing is testing the companion containers that support the main container, and that’s it’s not testing my internal API’s

[Solved]

I finally got it to work, and was able to deploy it today on my production server in release, production mode. It was a number of issues, one being how I programed Kestrel, my Dockerfile and how I built it and then using the right port numbers. Got the logs working and was finally able to solve the last of my code issues.

I was beginning to think that Microsoft didn’t want me to host it myself and to use Azure, which was kind of the case since I had to heavily modify the Docker file, and then modify it to run Angular wrapped in .Net Core. Who knows, would be interesting to try my image on Azure to see if it works.