简体   繁体   中英

issue with docker container with .net core 3.1 web app

I have created an MVC project with .net core 3.1 and enabled docker support, so I have the docker file in the project.

I am using Windows 10 Enterprise and Docker desktop community client for windows and it is running as a Windows container.

When I compile the project from the Visual Studio 2019, it creates the image and then the container, and by running: "docker container ls" I see it running.

I had to inspect the container to see the IP of the container and be able to run the page from the URL coming from the container. So having the IP of the container (172.24.121.233), I put this in the browser: http://172.24.121.233:80 and I see my web page. But the issue is after I stop running the MVC app from Visual Studio this URL does not work anymore?

I was expecting it to run independently? Any help to solve this issue and get the container running independently from Visual Studio?

Thanks

of course, you can run the docker container again: first, run docker ps -a (or if you don't run the container at all, docker images -a ), find your container (or image) and run it by the command docker run <IMAGE_NAME>

Two hints:

  • if you want to detach from the container after running it, use -d switch
  • if you want to access port 80 of your image without finding the container IP, use -p 180:80 and use your port 180 of host machine

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM