Fork me on GitHub

docker for windows & dotnet core app

 

 

Step 1: 安装docker for windows

Step 2: 从github 上 clone 源代码:https://github.com/dotnet/dotnet-docker-samples/

Step 3: 进入项目跟目录,运行docker build命令。

 

Step 4: build结束后使用 docker images 命令,查看生成的image

 

Step 5: 通过 docker run 命令 运行 image.

 

Step 6: 通过 docker tag 命令生成要push到 remote registry上的image. 注意这个image的命名规范(必须包含registry的名字,这里是yxzhk/oats).

 

Push to Azure Registry

 

az acr login ****不能work时用docker login 代替。

docker login <azure-container-registry-name>.azurecr.io --username <registry-username> --password <password> 

 

 

Create Container from Azure Registry

 

 

 

 

 

 

 

 

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/

 

posted @ 2017-06-29 15:54 ZHK的博客 阅读(...) 评论(...) 编辑 收藏