Step 1: 安裝docker for windowsgit
Step 2: 從github 上 clone 源代碼:https://github.com/dotnet/dotnet-docker-samples/github
Step 3: 進入項目跟目錄,運行docker build命令。docker
Step 4: build結束後使用 docker images 命令,查看生成的imagewindows
Step 5: 經過 docker run 命令 運行 image.bash
Step 6: 經過 docker tag 命令生成要push到 remote registry上的image. 注意這個image的命名規範(必須包含registry的名字,這裏是yxzhk/oats).app
Push to Azure Registryui
az acr login ****不能work時用docker login 代替。3d
docker login <azure-container-registry-name>.azurecr.io --username <registry-username> --password <password>
rest
Create Container from Azure Registrycode
Docker File:
FROM microsoft/dotnet:2.0-sdk AS build-env WORKDIR /app # copy csproj and restore as distinct layers COPY *.csproj ./ RUN dotnet restore # copy everything else and build COPY . ./ RUN dotnet publish -c Release -o out # build runtime image FROM microsoft/dotnet:2.0-runtime WORKDIR /app COPY --from=build-env /app/out ./ ENTRYPOINT ["dotnet", "HelloContainer.dll"]
docker ignore file:
bin/
obj/
PS: Docker 命令
https://docs.docker.com/engine/reference/commandline/docker/