How to run docker image produced by VS 2017

后端 未结 2 1427
[愿得一人]
[愿得一人] 2020-12-09 11:09

Docker noob here...

How does one properly run the docker image of your Asp.Net CORE app which is produced by Visual Studio 2017 at the command line?

         


        
2条回答
  •  攒了一身酷
    2020-12-09 11:42

    Yes, it is possible. Rebuild your solution in the Release configuration and try to run the docker-compose project with F5 to ensure the image is updated and your app is working fine. Then execute docker images console command. You'll see something like:

    REPOSITORY   TAG      IMAGE ID       CREATED              SIZE
    Your.App     latest   673b79a6bb3d   About a minute ago   294 MB
    

    All you need is to run a new container from that image and map its exposed port to a localhost port. By default, the exposed port is 80 (look at Dockerfile). For example:

    docker run -d -p 1234:80 --name some_name Your.App:latest
    

    Then your app should become accessible at http://127.0.0.1:1234/.

    Explanation:

    If the Debug configuration is set, then empty non-workable images are created by Visual Studio. It manually maps the empty container to the filesystem to make possible debugging, "Edit and Continue" features and so on. This is why dev image is useless without Visual Studio. Build the image in the Release configuration to make it usable.

    The full publishing process is described in the documentation: Visual Studio Tools for Docker

    Publishing Docker images

    Once you have completed the develop and debug cycle of your application, the Visual Studio Tools for Docker will help you create the production image of your application. Change the debug dropdown to Release and build the application. The tooling will produce the image with the :latest tag which you can push to your private registry or Docker Hub.

提交回复
热议问题