繁体   English   中英

Azure中的多步任务

[英]Multi step task in Azure

我根据 azure 中微软的教程创建了一个带有 yaml 的多步任务

az acr task create --registry pataugeoire --name multi-step --context https://github.com/myname/Planschbecken.git --file deploy-azure.yaml --git-access-token 1245

yaml 看起来是这样的

version: v1.0.0
steps:

- build: -t {{.Run.Registry}}/pataugeoire-eu:{{.Run.ID}} -f ./src/Planschbecken/build/Dockerfile .
# Run image 
- cmd: -t {{.Run.Registry}}/pataugeoire-eu:{{.Run.ID}}
  id: pataugeoire-eu
  detach: true
  ports: ["8080:80"]
- cmd: docker stop pataugeoire-eu
# Push image
- push:
  - {{.Run.Registry}}/pataugeoire-eu:{{.Run.ID}}

运行任务后我得到以下日志

2020/08/04 04:29:18 Downloading source code...
2020/08/04 04:29:22 Finished downloading source code
2020/08/04 04:29:22 Creating Docker network: acb_default_network, driver: 'bridge'
2020/08/04 04:29:22 Successfully set up Docker network: acb_default_network
2020/08/04 04:29:22 Setting up Docker configuration...
2020/08/04 04:29:23 Successfully set up Docker configuration
2020/08/04 04:29:23 Logging in to registry: pataugeoire.azurecr.io
2020/08/04 04:29:24 Successfully logged into pataugeoire.azurecr.io
2020/08/04 04:29:24 Executing step ID: acb_step_0. Timeout(sec): 600, Working directory: '', Network: 'acb_default_network'
2020/08/04 04:29:24 Scanning for dependencies...
2020/08/04 04:29:24 Successfully scanned dependencies
2020/08/04 04:29:24 Launching container with name: acb_step_0
Sending build context to Docker daemon  36.86kB
Step 1/16 : FROM mcr.microsoft.com/dotnet/core/aspnet:3.1-buster-slim AS base
3.1-buster-slim: Pulling from dotnet/core/aspnet
6ec8c9369e08: Pulling fs layer
fe8522826504: Pulling fs layer
658bf4619169: Pulling fs layer
0392978bbc2e: Pulling fs layer
33dd02257803: Pulling fs layer
0392978bbc2e: Waiting
33dd02257803: Waiting
658bf4619169: Verifying Checksum
658bf4619169: Download complete
fe8522826504: Verifying Checksum
fe8522826504: Download complete
6ec8c9369e08: Verifying Checksum
6ec8c9369e08: Download complete
0392978bbc2e: Verifying Checksum
0392978bbc2e: Download complete
33dd02257803: Verifying Checksum
33dd02257803: Download complete
6ec8c9369e08: Pull complete
fe8522826504: Pull complete
658bf4619169: Pull complete
0392978bbc2e: Pull complete
33dd02257803: Pull complete
Digest: sha256:8a92e24da3f05e870352a59318dc757fa8f439257aee72bd429fb32e8235c6a8
Status: Downloaded newer image for mcr.microsoft.com/dotnet/core/aspnet:3.1-buster-slim
 ---> 5d7a95ed1660
Step 2/16 : WORKDIR /app
 ---> Running in 0f7fe00fda83
Removing intermediate container 0f7fe00fda83
 ---> 1136339126be
Step 3/16 : EXPOSE 80
 ---> Running in 8d6c428499f2
Removing intermediate container 8d6c428499f2
 ---> aafe67b81817
Step 4/16 : FROM mcr.microsoft.com/dotnet/core/sdk:3.1-buster AS build
3.1-buster: Pulling from dotnet/core/sdk
31dd5ebca5ef: Pulling fs layer
3ed641c4ae98: Pulling fs layer
bcd57146431e: Pulling fs layer
ac34a4d7c330: Pulling fs layer
ea642ea828f8: Pulling fs layer
a6f91215615a: Pulling fs layer
9ab383195132: Pulling fs layer
ac34a4d7c330: Waiting
ea642ea828f8: Waiting
a6f91215615a: Waiting
9ab383195132: Waiting
3ed641c4ae98: Verifying Checksum
3ed641c4ae98: Download complete
bcd57146431e: Verifying Checksum
bcd57146431e: Download complete
ea642ea828f8: Verifying Checksum
ea642ea828f8: Download complete
31dd5ebca5ef: Verifying Checksum
31dd5ebca5ef: Download complete
ac34a4d7c330: Verifying Checksum
ac34a4d7c330: Download complete
a6f91215615a: Verifying Checksum
a6f91215615a: Download complete
9ab383195132: Verifying Checksum
9ab383195132: Download complete
31dd5ebca5ef: Pull complete
3ed641c4ae98: Pull complete
bcd57146431e: Pull complete
ac34a4d7c330: Pull complete
ea642ea828f8: Pull complete
a6f91215615a: Pull complete
9ab383195132: Pull complete
Digest: sha256:7aa45680ecf79dd9288056511c08b2c40411869b9ab89a0b51aade1f83fcc12e
Status: Downloaded newer image for mcr.microsoft.com/dotnet/core/sdk:3.1-buster
 ---> 925a86b607a3
Step 5/16 : WORKDIR /src
 ---> Running in 90742e31913f
Removing intermediate container 90742e31913f
 ---> 8b7410599293
Step 6/16 : COPY ["./src/Planschbecken/Planschbecken.csproj", ""]
 ---> 324f46346cf6
Step 7/16 : RUN dotnet restore "./Planschbecken.csproj"
 ---> Running in 246ad54a5b12
  Determining projects to restore...
  Restored /src/Planschbecken.csproj (in 1.04 sec).
Removing intermediate container 246ad54a5b12
 ---> ccc23072a246
Step 8/16 : COPY . .
 ---> 18b52c99b9ad
Step 9/16 : WORKDIR "/src/."
 ---> Running in 67e0a650d5af
Removing intermediate container 67e0a650d5af
 ---> 9426eacd4951
Step 10/16 : RUN dotnet build "Planschbecken.csproj" -c Release -o /app/build
 ---> Running in d665c57c7598
Microsoft (R) Build Engine version 16.6.0+5ff7b0c9e for .NET Core
Copyright (C) Microsoft Corporation. All rights reserved.

  Determining projects to restore...
  All projects are up-to-date for restore.
  Planschbecken -> /app/build/Planschbecken.dll

Build succeeded.
    0 Warning(s)
    0 Error(s)

Time Elapsed 00:00:02.30
Removing intermediate container d665c57c7598
 ---> 39254ff6b129
Step 11/16 : FROM build AS publish
 ---> 39254ff6b129
Step 12/16 : RUN dotnet publish "Planschbecken.csproj" -c Release -o /app/publish
 ---> Running in 26bd2e4d0e21
Microsoft (R) Build Engine version 16.6.0+5ff7b0c9e for .NET Core
Copyright (C) Microsoft Corporation. All rights reserved.

  Determining projects to restore...
  All projects are up-to-date for restore.
  Planschbecken -> /src/bin/Release/netcoreapp3.1/Planschbecken.dll
  Planschbecken -> /app/publish/
Removing intermediate container 26bd2e4d0e21
 ---> 9cfd1ab1a249
Step 13/16 : FROM base AS final
 ---> aafe67b81817
Step 14/16 : WORKDIR /app
 ---> Running in ac345cd72236
Removing intermediate container ac345cd72236
 ---> 526f22fd95d0
Step 15/16 : COPY --from=publish /app/publish .
 ---> 02da76c66090
Step 16/16 : ENTRYPOINT ["dotnet", "Planschbecken.dll"]
 ---> Running in 748b1470c1e3
Removing intermediate container 748b1470c1e3
 ---> 8e16f072fb69
Successfully built 8e16f072fb69
Successfully tagged pataugeoire.azurecr.io/pataugeoire-eu:cb1s
2020/08/04 04:30:04 Successfully executed container: acb_step_0
2020/08/04 04:30:04 Executing step ID: pataugeoire-eu. Timeout(sec): 600, Working directory: '', Network: 'acb_default_network'
2020/08/04 04:30:04 Launching container with name: pataugeoire-eu
e61815831412e20351a491d0318863c28171cb2d23f6e373214703706fde4223
2020/08/04 04:30:05 Successfully executed container: pataugeoire-eu
2020/08/04 04:30:05 Executing step ID: acb_step_2. Timeout(sec): 600, Working directory: '', Network: 'acb_default_network'
2020/08/04 04:30:05 Launching container with name: acb_step_2
Error response from daemon: No such container: pataugeoire-eu
2020/08/04 04:30:06 Container failed during run: acb_step_2. No retries remaining.
failed to run step ID: acb_step_2: exit status 1

一切看起来都很好。 但最终脚本停止工作。 由于网站仍在运行,docker 似乎仍处于活动状态。 我做错了什么?

最后有一条错误信息:

没有这样的容器:pataugeoire-eu

这可能是因为您试图在容器被推送之前运行它。

如果你想在完成构建时运行你的 Docker 图像,你可以使用cmd并使用注册表名称设置图像:

- cmd: $Registry/myimage:mytag

所以你不需要使用docker run命令,而且,你错过了镜像的注册表名称。 以下是有关任务中cmd的更多详细信息。 它还显示了描述:

假定没有以注册表开头的图像源自 docker.io。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM