Docker

Introduction

Reference:

Prerequisites:

.NetCore
Docker
Postman
VsCode

Tip: If you want to run VS Code from the terminal, append the following to your ~/.bash_profile file (~/.zshrc in case you use zsh).

Shell
1
vim ~/.zshrc
Add the following to the last line
1
code () { VSCODE_CWD="$PWD" open -n -b "com.microsoft.VSCode" --args $* ;}
Shell
1
2
:x
source ~/.zshrc

For the simplest local test, we disable https

.Net
1
dotnet new webapi -o HelloAspNetCore --no-https

.Net
1
2
cd HelloAspNetCore
code .

Click Yes

Run WeatherForecastController.cs in VsCode

Open Postman to test, Click Send

Install Docker extension in VsCode

Press Command + P, input >Docker: Add Docker Files to Workspace, then choose your API directory, then select .NetCore, Linux, No, 80

remove this line

Docker
1
docker build -t hello-aspnetcore:v1

Docker
1
docker images

Docker
1
docker run -it --rm -p 8080:80 hello-aspnetcore:v1 

Press Ctrl + c to exit the docker process.