共用方式為


DockerCompose@1 - Docker Compose v1 任務

建置、推送或執行多容器 Docker 應用程式。 工作可以搭配 Docker 或 Azure Container Registry 使用。

語法

# Docker Compose v1
# Build, push or run multi-container Docker applications. Task can be used with Docker or Azure Container registry.
- task: DockerCompose@1
  inputs:
    containerregistrytype: 'Azure Container Registry' # 'Azure Container Registry' | 'Container Registry'. Required. Container Registry Type. Default: Azure Container Registry.
    #dockerRegistryEndpoint: # string. Optional. Use when containerregistrytype = Container Registry. Docker Registry Service Connection. 
    #azureSubscription: # string. Alias: azureSubscriptionEndpoint. Optional. Use when containerregistrytype = Azure Container Registry. Azure subscription. 
    #azureContainerRegistry: # string. Optional. Use when containerregistrytype = Azure Container Registry. Azure Container Registry. 
    dockerComposeFile: '**/docker-compose.yml' # string. Required. Docker Compose File. Default: **/docker-compose.yml.
    #additionalDockerComposeFiles: # string. Additional Docker Compose Files. 
    #dockerComposeFileArgs: # string. Environment Variables. 
    #projectName: '$(Build.Repository.Name)' # string. Project Name. Default: $(Build.Repository.Name).
    #qualifyImageNames: true # boolean. Qualify Image Names. Default: true.
    action: 'Run a Docker Compose command' # 'Build services' | 'Push services' | 'Run services' | 'Run a specific service' | 'Lock services' | 'Write service image digests' | 'Combine configuration' | 'Run a Docker Compose command'. Required. Action. Default: Run a Docker Compose command.
    #additionalImageTags: # string. Optional. Use when action = Build services || action = Push services. Additional Image Tags. 
    #includeSourceTags: false # boolean. Optional. Use when action = Build services || action = Push services. Include Source Tags. Default: false.
    #includeLatestTag: false # boolean. Optional. Use when action = Build services || action = Push services. Include Latest Tag. Default: false.
    #buildImages: true # boolean. Optional. Use when action = Run services. Build Images. Default: true.
    #serviceName: # string. Required when action = Run a specific service. Service Name. 
    #containerName: # string. Optional. Use when action = Run a specific service. Container Name. 
    #ports: # string. Optional. Use when action = Run a specific service. Ports. 
    #workingDirectory: # string. Alias: workDir. Optional. Use when action = Run a specific service. Working Directory. 
    #entrypoint: # string. Optional. Use when action = Run a specific service. Entry Point Override. 
    #containerCommand: # string. Optional. Use when action = Run a specific service. Command. 
    #detached: true # boolean. Optional. Use when action = Run services || action = Run a specific service. Run in Background. Default: true.
    #abortOnContainerExit: true # boolean. Optional. Use when action = Run services && detached == false. Abort on Container Exit. Default: true.
    #imageDigestComposeFile: '$(Build.StagingDirectory)/docker-compose.images.yml' # string. Required when action = Write service image digests. Image Digest Compose File. Default: $(Build.StagingDirectory)/docker-compose.images.yml.
    #removeBuildOptions: false # boolean. Optional. Use when action = Lock services || action = Combine configuration. Remove Build Options. Default: false.
    #baseResolveDirectory: # string. Optional. Use when action = Lock services || action = Combine configuration. Base Resolve Directory. 
    #outputDockerComposeFile: '$(Build.StagingDirectory)/docker-compose.yml' # string. Required when action = Lock services || action = Combine configuration. Output Docker Compose File. Default: $(Build.StagingDirectory)/docker-compose.yml.
    #dockerComposeCommand: # string. Required when action = Run a Docker Compose command. Command. 
    #arguments: # string. Optional. Use when action != Lock services && action != Combine configuration && action != Write service image digests. Arguments. 
  # Advanced Options
    #dockerHostEndpoint: # string. Docker Host Service Connection. 
    #nopIfNoDockerComposeFile: false # boolean. No-op if no Docker Compose File. Default: false.
    #requireAdditionalDockerComposeFiles: false # boolean. Require Additional Docker Compose Files. Default: false.
    #currentWorkingDirectory: '$(System.DefaultWorkingDirectory)' # string. Alias: cwd. Working Directory. Default: $(System.DefaultWorkingDirectory).
    #dockerComposePath: # string. Docker Compose executable Path.

輸入

containerregistrytype - Container Registry 類型
string。 必須的。 允許的值:Azure Container RegistryContainer Registry。 預設值: Azure Container Registry

選擇 Container Registry Type(容器註冊表類型)。


dockerRegistryEndpoint - Docker Registry Service 連線
string。 選擇性。 containerregistrytype = Container Registry時使用 。

選取 Docker 登錄服務連線。 需要用於需要向登錄進行驗證的命令。


azureSubscription - Azure 訂用帳戶
輸入別名azureSubscriptionEndpointstring。 選擇性。 containerregistrytype = Azure Container Registry時使用 。

選取 Azure 訂用帳戶。


azureContainerRegistry - Azure 容器註冊表
string。 選擇性。 containerregistrytype = Azure Container Registry時使用 。

選擇 Azure 容器註冊表。


dockerComposeFile - Docker Compose 檔案
string。 必須的。 預設值: **/docker-compose.yml

要使用的主 Docker Compose 檔的路徑。


additionalDockerComposeFiles - 其他 Docker Compose 檔案
string

要與主 Docker Compose 檔合併的其他 Docker Compose 檔。 相對路徑會相對於包含主要 Docker Compose 檔案的目錄解析。 如果找不到指定的檔案,則會忽略它。 在新行上指定每個檔案路徑。


dockerComposeFileArgs - 環境變數
string

要在命令期間設置的環境變數。 在新行上指定每個 name=value 對。


projectName - 項目名稱
string。 預設值: $(Build.Repository.Name)

用於映像和容器的預設命名的項目名稱。


qualifyImageNames - 限定映像名稱
boolean。 預設值: true

如果未另行指定,請使用 Docker 註冊表服務連接的主機名限定構建服務的映像名稱。


action - 動作
string。 必須的。 允許的值:Build services(建置服務映射)、Push services(推送服務映射)、Run services(執行服務映射)、Run a specific service(執行特定服務映射)、Lock services(鎖定服務映射)、Write service image digestsCombine configurationRun a Docker Compose command。 預設值: Run a Docker Compose command

選擇 Docker Compose作。


additionalImageTags - 其他影像標記
string。 選擇性。 action = Build services || action = Push services時使用 。

正在構建或推送的 Docker 鏡像的其他標籤。


includeSourceTags - 包含來源標籤
boolean。 選擇性。 action = Build services || action = Push services時使用 。 預設值: false

在構建或推送 Docker 鏡像時包含 Git 標籤。


includeLatestTag - 包含最新的標籤
boolean。 選擇性。 action = Build services || action = Push services時使用 。 預設值: false

在構建或推送 Docker 鏡像時包含 'latest' 標籤。


buildImages - 建置映像
boolean。 選擇性。 action = Run services時使用 。 預設值: true

在啟動服務容器之前構建鏡像。


serviceName - 服務名稱
stringaction = Run a specific service時為必要項。

要運行的特定服務的名稱。


containerName - 容器名稱
string。 選擇性。 action = Run a specific service時使用 。

要運行的特定服務容器的名稱。


ports -
string。 選擇性。 action = Run a specific service時使用 。

要發佈到主機的特定服務容器中的埠。 在新行上指定每個 host-port:container-port 綁定。


workingDirectory - 工作目錄
輸入別名workDirstring。 選擇性。 action = Run a specific service時使用 。

特定服務容器的工作目錄。


entrypoint - 進入點覆寫
string。 選擇性。 action = Run a specific service時使用 。

覆蓋特定服務容器的預設入口點。


containerCommand - 命令
string。 選擇性。 action = Run a specific service時使用 。

命令。 例如,如果圖像包含一個簡單的 Python Flask Web 應用程式,您可以指定“python app.py”來啟動 Web 應用程式。


在背景執行 detached -
boolean。 選擇性。 action = Run services || action = Run a specific service時使用 。 預設值: true

在後台運行服務容器。


容器結束 abortOnContainerExit - 中止
boolean。 選擇性。 action = Run services && detached == false時使用 。 預設值: true

當任何容器退出時停止所有容器。


imageDigestComposeFile - 影像摘要撰寫檔案
stringaction = Write service image digests時為必要項。 預設值: $(Build.StagingDirectory)/docker-compose.images.yml

Docker Compose 檔案的路徑,該檔創建並填充了每個服務的 Docker 映像的完整映射儲存庫摘要。


removeBuildOptions - 移除建置選項
boolean。 選擇性。 action = Lock services || action = Combine configuration時使用 。 預設值: false

從輸出 Docker Compose 檔中刪除構建選項。


baseResolveDirectory - 基底解析目錄
string。 選擇性。 action = Lock services || action = Combine configuration時使用 。

應從中解析輸出 Docker Compose 檔中的相對路徑的基目錄。


outputDockerComposeFile - 輸出 Docker Compose 檔案
stringaction = Lock services || action = Combine configuration時為必要項。 預設值: $(Build.StagingDirectory)/docker-compose.yml

輸出 Docker Compose 檔的路徑。


dockerComposeCommand - 命令
stringaction = Run a Docker Compose command時為必要項。

Docker Compose 命令執行。 例如,『rm --all』 可刪除所有已停止的服務容器。


arguments - 自變數
string。 選擇性。 action != Lock services && action != Combine configuration && action != Write service image digests時使用 。

Docker Compose 命令選項。 例如:
對於 build 命令,
--pull --compress --parallel 來。


dockerHostEndpoint - Docker 主機服務連線
string

選擇 Docker 主機服務連接。 預設為代理程式的主機。


如果沒有 Docker Compose 檔案nopIfNoDockerComposeFile - No-op
boolean。 預設值: false

如果 Docker Compose 檔不存在,請跳過此任務。 當任務根據存儲庫中是否存在 Docker Compose 檔提供可選行為時,這非常有用。


requireAdditionalDockerComposeFiles - 需要額外的 Docker Compose 檔案
boolean。 預設值: false

如果其他 Docker Compose 檔不存在,則生成錯誤。 這將覆蓋預設行為,即忽略不存在的檔。


currentWorkingDirectory - 工作目錄
輸入別名cwdstring。 預設值: $(System.DefaultWorkingDirectory)

Docker Compose 命令的工作目錄。


dockerComposePath - Docker Compose 可執行文件路徑
string

如果提供了路徑,則將使用此 docker-compose 可執行檔。


工作控制選項

除了工作輸入之外,所有工作都有控制選項。 如需詳細資訊,請參閱 控制項選項和一般工作屬性

輸出變數

此工作會定義下列 輸出變數,您可以在下游步驟、作業和階段中取用這些變數。

DockerComposeOutput
包含命令輸出的檔案的路徑。 對於 dockerComposeRun 命令(一個用於運行,一個用於關閉)、dockerPush(一個用於推送的每個映射)、dockerBuild(構建本身和所有標記命令)和 dockerDigest(一個用於每個提取的映射),這可以包含多個文件路徑(以換行符分隔)。 其他命令只會輸出一個檔案。

需求

要求 說明
管線類型 YAML、傳統組建、傳統版本
執行於 Agent、DeploymentGroup
要求 沒有
能力 此工作不符合作業中後續工作的任何需求。
命令限制 任意
Settable 變數 任意
代理程式版本 所有支援的代理程式版本。
工作類別 建造