- ASP.NET Core 2 High Performance(Second Edition)
- James Singleton
- 271字
- 2021-07-08 09:39:08
Using ASP.NET Core 2 with Docker
Now that we've checked Docker is working and can run .NET Core, it's time for something a bit more complex. We're going to interactively log in to a container and create an ASP.NET Core 2 app inside.
Run the following command:
sudo docker run -it --rm microsoft/aspnetcore-build:2
Once the image is downloaded, you should get a slightly different command prompt. Let's be more ambitious and create a single page app using the React and Redux JavaScript libraries:
dotnet new reactredux -o AspNetCoreTwoDocker
Next we need to restore the JS packages from npm. Note that we haven't installed npm (or .NET Core); it has come included in the container image:
cd AspNetCoreTwoDocker
npm install
Let's run the app in the background again and download the home page. Note that the Kestrel web server is now running on the default HTTP port of 80, so we don't need to specify an alternative non-standard port number:
dotnet run &
wget localhost
This is shown in the following screenshot:

The Docker image doesn't contain a text editor, but we can still view the contents of the file with the cat command. We won't get any syntax highlighting, but we can clearly see that this is a React app, as our server rendered the initial state into the page (as div with id of react-app):
cat index.html
The React app HTML page source, displayed in the terminal using cat, is shown in the following screenshot:

You can again tidy up the dotnet process with kill and leave the Docker container to return to your host VM with the exit command.
- Arduino開發(fā)實戰(zhàn)指南:LabVIEW卷
- Visual C++串口通信技術詳解(第2版)
- Silverlight魔幻銀燈
- Java 11 Cookbook
- 快人一步:系統(tǒng)性能提高之道
- 大學計算機基礎實驗指導
- ASP.NET開發(fā)與應用教程
- Internet of Things with ESP8266
- Java Web開發(fā)基礎與案例教程
- 數(shù)據庫技術及應用教程上機指導與習題(第2版)
- Responsive Web Design with HTML5 and CSS3(Second Edition)
- React Native -Building Mobile Apps with JavaScript
- 微信小程序開發(fā)實戰(zhàn)教程(PHP+Laravel+MySQL)(微課版)
- 胸有成竹!數(shù)據分析的SPSS和SAS EG進階(第2版)
- Deep Learning with TensorFlow(Second Edition)