Run ASP. NET Core Web API application in docker (with AWS Windows Server 2016 widt Container case), dockeraws
Environment preparation
1. Amazon EC2 Windows Server 2016 with Container
2. Visual Studio 2015 Enterprise (Update required for Profresianal)
3.. NET Core 1.0.0-VS 2015 Tooling Preview 2. Click here to install
4. Microsoft. NET Core SDK, which can be downloaded and installed on the official Microsoft website
5. Visual Stuido Tool For Docker (download and install it in VS extension)
Lab procedure
I. Prepare the Docker Environment
Amazon EC2 Windows Server 2016 with Container has built-in Docker, as shown below:
Click search in the lower left corner of Windows and enter "Server Manager ",
Add Role or Featurn to the right of the Dashboard
Unlike servers, roles and features are added together. Click Next here and find that Hyper-V in Roles is not enabled. Many people say they want to enable it. I didn't enable it here.
There is a Container in features. This is Docker.
Verify that Docker is installed. Run the following command under CMD to verify the installation:
If docker info can be identified and executed, it indicates that Docker has been installed successfully.
2. Develop ASP. NET Core WebApi
Before starting VS2015, make sure that DotNetCore.1.0.1-VS2015Tools. Preview2.0.2 and Visual Stuido Tool For Docker are installed (download and install in VS extension)
Comment out the Dockerfile generated by the tool. Otherwise, an error will be reported when running the docker run Command (dotnet dockerwebapidemo. dll needs to be run in powershell)
Save automatic compilation and run dotnet publish in the root directory of the program. The publish folder is automatically compiled and generated in bin.
Run docker build in the publish folder to generate a docker image.
Note that the last vertex indicates the current path.
View the generated image
Run containers
Docker run-it-p 8600: 5000 xucixiao/dockerwebapidemo
The following interface is returned to indicate that the container is successfully started.