Home Running .NET framework console-app service on Docker
Reply: 0

Running .NET framework console-app service on Docker

user1966
1#
user1966 Published in May 23, 2018, 10:45 pm

I'm trying to get a service on-boarded to Docker containers. Target Framework - .NET Framework 4.6.1 Output type - Console Application

When I initially tried to right click -> Add -> Docker Support on the project in the Visual Studio 2017 sln I got a prompt "You cannot add Docker support to this project type"

I went ahead and created a Dockerfile by hand and placed it in the root. This is what it looks like:

FROM microsoft/windowsservercore

SHELL ["powershell", "-command"]

RUN Add-WindowsFeature NET-Framework-45-ASPNET, Web-Asp-Net45

EXPOSE 80
EXPOSE 5000
EXPOSE 13134

ADD ./bin/Debug/net461/win7-x64 .
COPY ./bin/cert-that-needs-to-be-installed.pfx /cert-that-needs-to-be-installed.pfx

RUN $Secure_String_Pwd = ConvertTo-SecureString "thePasswordToTheCert!" -AsPlainText -Force; \
    Import-PfxCertificate -FilePath .\cert-that-needs-to-be-installed.pfx  -CertStoreLocation Cert:\LocalMachine\My -Exportable -Password $Secure_String_Pwd;

ENV ASPNETCORE_ENVIRONMENT="Development"
ENTRYPOINT ["./ServiceName.exe"]

Upon doing the following, I was able to successfully create an image and also a container with the service running on it: (the prod version listens on port 5000 while the test one listens on 13134 and those ports are also open in my localhost Firewall)

docker build -t ServiceName .; docker run -p 5000:5000 -p 13134:13134 -it ServiceName

I am able to get the ip of the container by doing this:

docker inspect <containerId>

Now when I try to test the service by doing a HttpGet call to an API using Postman I don't get a response. I have the docker container open in my cmd prompt and I don't see my request coming in either.

My service works fine on a Windows VM. Since my GET calls don't even seem to reach the container I fear I am doing the port mapping wrong/or is it something else?

You need to login account before you can post.

About| Privacy statement| Terms of Service| Advertising| Contact us| Help| Sitemap|
Processed in 0.300686 second(s) , Gzip On .

© 2016 Powered by mzan.com design MATCHINFO