2

I am new to docker and windows container world. I am creating a sample application using ASP.NET Core 2.0 with SQL Server 2016 Backend. I am able to run the application successfully directly on Windows Server 2016 VM. Next I containerized it using Docker EE Windows Container. I started the container and able to browse the application from Windows Server 2016 VM host.

This is how I build and started the container, please assume I have created the .dockerfile with appropriate values.

docker build -t testapi .

docker run -d --name testapi_app --rm -it -p 8000:80 testapi

When I run

docker network ls

I get

NETWORK ID          NAME                DRIVER              SCOPE
38c9f8e165bf        nat                 nat                 local
f97c096a0ef6        none                null                local

When I run following command (02f4 is the container id first 4 characters)

docker exec 02f4 ipconfig

I can see the IPv4 address as 172.25.5.26

I am able to browse the application from host windows server 2016 VM using http://172.25.5.26/api/values

And I am getting the response back.

I will really appreciate if anyone can point me to some resources that can help me with how to make the application hosted with windows container using docker EE on a windows server 2016 VM host to be browsable from outside the host VM.

I feel like I may have to change some network options, but not exactly sure what is that I must change.

Any help will be greatly appreciated.

OneCricketeer
  • 179,855
  • 19
  • 132
  • 245
jbl
  • 123
  • 7
  • 1
    I believe this question would be better asked (and answered) on [serverfault](https://serverfault.com/) as it is more configuration and setup of a hosted environment rather than direct coding related. – John Mitchell May 08 '18 at 01:37
  • Good suggestion, Thank you. I will post the question there. – jbl May 08 '18 at 01:39
  • 2
    Do you understand what `-p 8000:80` is doing? Why did you think you needed the container IP? – OneCricketeer May 08 '18 at 01:40
  • 2
    @cricket_007, thank you. I was just following the tutorial and didn't pay attention to -p 8000:80, after you asked the question, then I realized that the -p is exposing port 80 of container to 8000 port on host. I am now able to access the application. Instead of trying to browse http://172.25.5.26/api/values, I had to access it from outside using http://:8000/api/values – jbl May 08 '18 at 01:47
  • 1
    Yup, that's how to do it ;) – OneCricketeer May 08 '18 at 01:53

0 Answers0