Compartir a través de


Docker@0: tarea de Docker v0

Compile, etiquete, inserte, ejecute imágenes de Docker o ejecute un comando de Docker. Use esta tarea con Docker o Azure Container Registry.

Nota

Docker@2 es una versión más reciente de esta tarea que simplifica la tarea quitando entradas que se pueden pasar como argumentos al comando.

Syntax

# Docker v0
# Build, tag, push, or run Docker images, or run a Docker command.
- task: Docker@0
  inputs:
    containerregistrytype: 'Azure Container Registry' # 'Azure Container Registry' | 'Container Registry'. Required. Container Registry Type. Default: Azure Container Registry.
    #dockerRegistryConnection: # string. Alias: dockerRegistryEndpoint. 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. 
    action: 'Build an image' # 'Build an image' | 'Tag images' | 'Push an image' | 'Push images' | 'Run an image' | 'Run a Docker command'. Required. Action. Default: Build an image.
    #dockerFile: '**/Dockerfile' # string. Required when action = Build an image. Docker File. Default: **/Dockerfile.
    #buildArguments: # string. Optional. Use when action = Build an image. Build Arguments. 
    #defaultContext: true # boolean. Optional. Use when action = Build an image. Use Default Build Context. Default: true.
    #context: # string. Optional. Use when action = Build an image && defaultContext = false. Build Context. 
    #imageName: '$(Build.Repository.Name):$(Build.BuildId)' # string. Required when action == Build an image || action == Push an image || action == Run an image. Image Name. Default: $(Build.Repository.Name):$(Build.BuildId).
    #imageNamesPath: # string. Required when action == Tag images || action == Push images. Image Names Path. 
    #qualifyImageName: true # boolean. Optional. Use when action = Build an image || action = Tag images || action = Push an image || action = Push images || action = Run an image. Qualify Image Name. Default: true.
    #additionalImageTags: # string. Optional. Use when action = Build an image || action = Tag images || action = Push an image || action = Push images. Additional Image Tags. 
    #includeSourceTags: false # boolean. Optional. Use when action = Build an image || action = Tag image || action = Push an image || action = Push images. Include Source Tags. Default: false.
    #includeLatestTag: false # boolean. Optional. Use when action = Build an image || action = Push an image || action = Push images. Include Latest Tag. Default: false.
    #imageDigestFile: # string. Optional. Use when action = Push an image || action = Push images. Image Digest File. 
    #containerName: # string. Optional. Use when action = Run an image. Container Name. 
    #ports: # string. Optional. Use when action = Run an image. Ports. 
    #volumes: # string. Optional. Use when action = Run an image. Volumes. 
    #envVars: # string. Optional. Use when action = Run an image. Environment Variables. 
    #workDir: # string. Optional. Use when action = Run an image. Working Directory. 
    #entrypoint: # string. Optional. Use when action = Run an image. Entry Point Override. 
    #containerCommand: # string. Optional. Use when action = Run an image. Command. 
    #detached: true # boolean. Optional. Use when action = Run an image. Run In Background. Default: true.
    #restartPolicy: 'no' # 'no' | 'onFailure' | 'always' | 'unlessStopped'. Required when action = Run an image && detached = true. Restart Policy. Default: no.
    #restartMaxRetries: # string. Optional. Use when action = Run an image && detached = true && restartPolicy = onFailure. Maximum Restart Retries. 
    #customCommand: # string. Required when action = Run a Docker command. Command. 
  # commands
    #addBaseImageData: true # boolean. Add base image metadata to image(s). Default: true.
  # Advanced Options
    #dockerHostEndpoint: # string. Docker Host Service Connection. 
    #enforceDockerNamingConvention: true # boolean. Force image name to follow Docker naming convention. Default: true.
    #workingDirectory: '$(System.DefaultWorkingDirectory)' # string. Alias: cwd. Working Directory. Default: $(System.DefaultWorkingDirectory).
    #memory: # string. Memory limit.
# Docker v0
# Build, tag, push, or run Docker images, or run a Docker command.
- task: Docker@0
  inputs:
    containerregistrytype: 'Azure Container Registry' # 'Azure Container Registry' | 'Container Registry'. Required. Container Registry Type. Default: Azure Container Registry.
    #dockerRegistryConnection: # string. Alias: dockerRegistryEndpoint. 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. 
    action: 'Build an image' # 'Build an image' | 'Tag images' | 'Push an image' | 'Push images' | 'Run an image' | 'Run a Docker command'. Required. Action. Default: Build an image.
    #dockerFile: '**/Dockerfile' # string. Required when action = Build an image. Docker File. Default: **/Dockerfile.
    #buildArguments: # string. Optional. Use when action = Build an image. Build Arguments. 
    #defaultContext: true # boolean. Optional. Use when action = Build an image. Use Default Build Context. Default: true.
    #context: # string. Optional. Use when action = Build an image && defaultContext = false. Build Context. 
    #imageName: '$(Build.Repository.Name):$(Build.BuildId)' # string. Required when action == Build an image || action == Push an image || action == Run an image. Image Name. Default: $(Build.Repository.Name):$(Build.BuildId).
    #imageNamesPath: # string. Required when action == Tag images || action == Push images. Image Names Path. 
    #qualifyImageName: true # boolean. Optional. Use when action = Build an image || action = Tag images || action = Push an image || action = Push images || action = Run an image. Qualify Image Name. Default: true.
    #additionalImageTags: # string. Optional. Use when action = Build an image || action = Tag images || action = Push an image || action = Push images. Additional Image Tags. 
    #includeSourceTags: false # boolean. Optional. Use when action = Build an image || action = Tag image || action = Push an image || action = Push images. Include Source Tags. Default: false.
    #includeLatestTag: false # boolean. Optional. Use when action = Build an image || action = Push an image || action = Push images. Include Latest Tag. Default: false.
    #imageDigestFile: # string. Optional. Use when action = Push an image || action = Push images. Image Digest File. 
    #containerName: # string. Optional. Use when action = Run an image. Container Name. 
    #ports: # string. Optional. Use when action = Run an image. Ports. 
    #volumes: # string. Optional. Use when action = Run an image. Volumes. 
    #envVars: # string. Optional. Use when action = Run an image. Environment Variables. 
    #workDir: # string. Optional. Use when action = Run an image. Working Directory. 
    #entrypoint: # string. Optional. Use when action = Run an image. Entry Point Override. 
    #containerCommand: # string. Optional. Use when action = Run an image. Command. 
    #detached: true # boolean. Optional. Use when action = Run an image. Run In Background. Default: true.
    #restartPolicy: 'no' # 'no' | 'onFailure' | 'always' | 'unlessStopped'. Required when action = Run an image && detached = true. Restart Policy. Default: no.
    #restartMaxRetries: # string. Optional. Use when action = Run an image && detached = true && restartPolicy = onFailure. Maximum Restart Retries. 
    #customCommand: # string. Required when action = Run a Docker command. Command. 
  # Advanced Options
    #dockerHostEndpoint: # string. Docker Host Service Connection. 
    #enforceDockerNamingConvention: true # boolean. Force image name to follow Docker naming convention. Default: true.
    #workingDirectory: '$(System.DefaultWorkingDirectory)' # string. Alias: cwd. Working Directory. Default: $(System.DefaultWorkingDirectory).
    #memory: # string. Memory limit.
# Docker v0
# Build, tag, push, or run Docker images, or run a Docker command. Task can be used with Docker or Azure Container registry.
- task: Docker@0
  inputs:
    containerregistrytype: 'Azure Container Registry' # 'Azure Container Registry' | 'Container Registry'. Required. Container Registry Type. Default: Azure Container Registry.
    #dockerRegistryConnection: # string. Alias: dockerRegistryEndpoint. 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. 
    action: 'Build an image' # 'Build an image' | 'Tag images' | 'Push an image' | 'Push images' | 'Run an image' | 'Run a Docker command'. Required. Action. Default: Build an image.
    #dockerFile: '**/Dockerfile' # string. Required when action = Build an image. Docker File. Default: **/Dockerfile.
    #buildArguments: # string. Optional. Use when action = Build an image. Build Arguments. 
    #defaultContext: true # boolean. Optional. Use when action = Build an image. Use Default Build Context. Default: true.
    #context: # string. Optional. Use when action = Build an image && defaultContext = false. Build Context. 
    #imageName: '$(Build.Repository.Name):$(Build.BuildId)' # string. Required when action == Build an image || action == Push an image || action == Run an image. Image Name. Default: $(Build.Repository.Name):$(Build.BuildId).
    #imageNamesPath: # string. Required when action == Tag images || action == Push images. Image Names Path. 
    #qualifyImageName: true # boolean. Optional. Use when action = Build an image || action = Tag images || action = Push an image || action = Push images || action = Run an image. Qualify Image Name. Default: true.
    #additionalImageTags: # string. Optional. Use when action = Build an image || action = Tag images || action = Push an image || action = Push images. Additional Image Tags. 
    #includeSourceTags: false # boolean. Optional. Use when action = Build an image || action = Tag image || action = Push an image || action = Push images. Include Source Tags. Default: false.
    #includeLatestTag: false # boolean. Optional. Use when action = Build an image || action = Push an image || action = Push images. Include Latest Tag. Default: false.
    #imageDigestFile: # string. Optional. Use when action = Push an image || action = Push images. Image Digest File. 
    #containerName: # string. Optional. Use when action = Run an image. Container Name. 
    #ports: # string. Optional. Use when action = Run an image. Ports. 
    #volumes: # string. Optional. Use when action = Run an image. Volumes. 
    #envVars: # string. Optional. Use when action = Run an image. Environment Variables. 
    #workDir: # string. Optional. Use when action = Run an image. Working Directory. 
    #entrypoint: # string. Optional. Use when action = Run an image. Entry Point Override. 
    #containerCommand: # string. Optional. Use when action = Run an image. Command. 
    #detached: true # boolean. Optional. Use when action = Run an image. Run In Background. Default: true.
    #restartPolicy: 'no' # 'no' | 'onFailure' | 'always' | 'unlessStopped'. Required when action = Run an image && detached = true. Restart Policy. Default: no.
    #restartMaxRetries: # string. Optional. Use when action = Run an image && detached = true && restartPolicy = onFailure. Maximum Restart Retries. 
    #customCommand: # string. Required when action = Run a Docker command. Command. 
  # Advanced Options
    #dockerHostEndpoint: # string. Docker Host Service Connection. 
    #enforceDockerNamingConvention: true # boolean. Force image name to follow Docker naming convention. Default: true.
    #workingDirectory: '$(System.DefaultWorkingDirectory)' # string. Alias: cwd. Working Directory. Default: $(System.DefaultWorkingDirectory).
    #memory: # string. Memory limit.

Entradas

containerregistrytype - Tipo de registro de contenedor
string. Obligatorio. Valores permitidos: Azure Container Registry, Container Registry. Valor predeterminado: Azure Container Registry.

Seleccione "Azure Container Registry" para conectarse a él mediante una conexión de servicio de Azure. Seleccione "Container Registry" para conectarse a Docker Hub o a cualquier otro registro de contenedor privado.


dockerRegistryConnection - Conexión del servicio del registro de Docker
Alias de entrada: dockerRegistryEndpoint. string. Opcional. Use cuando containerregistrytype = Container Registry.

Especifica una conexión de servicio del registro de Docker. Obligatorio para los comandos que necesitan autenticarse con un registro.


azureSubscription - Suscripción de Azure
Alias de entrada: azureSubscriptionEndpoint. string. Opcional. Use cuando containerregistrytype = Azure Container Registry.

Especifica una suscripción de Azure.


azureContainerRegistry - Azure Container Registry
string. Opcional. Use cuando containerregistrytype = Azure Container Registry.

Especifica un Azure Container Registry en la suscripción de Azure seleccionada. La imagen de contenedor se compila y, a continuación, se inserta en este registro de contenedor.


action - Acción
string. Obligatorio. Valores permitidos: Build an image, , Tag imagesPush an image, Push images, Run an image, . Run a Docker command Valor predeterminado: Build an image.

Especifica una acción de Docker.


dockerFile - Archivo docker
string. Necesario cuando action = Build an image. Valor predeterminado: **/Dockerfile.

Especifica la ruta de acceso al archivo de Docker. La tarea usa el primer archivo de Docker que encuentra para compilar la imagen.


addBaseImageData - Adición de metadatos de imagen base a imágenes
boolean. Valor predeterminado: true.

El valor predeterminado agrega datos de imagen base como, por ejemplo, el nombre de la imagen base y el resumen para ayudar con la rastreabilidad. Puede optar por no participar estableciendo el valor en false.


buildArguments - Argumentos de compilación
string. Opcional. Use cuando action = Build an image.

Especifica variables en tiempo de compilación para el archivo de Docker. Dar formato a cada name=value par en una nueva línea.


defaultContext - Usar el contexto de compilación predeterminado
boolean. Opcional. Use cuando action = Build an image. Valor predeterminado: true.

Especifica el contexto de compilación del directorio que contiene el archivo de Docker.


context - Contexto de compilación
string. Opcional. Use cuando action = Build an image && defaultContext = false.

Especifica la ruta de acceso al contexto de compilación.


imageName - Nombre de la imagen
string. Necesario cuando action == Build an image || action == Push an image || action == Run an image. Valor predeterminado: $(Build.Repository.Name):$(Build.BuildId).

Especifica el nombre de la imagen de Docker que se va a compilar, insertar o ejecutar.


imageNamesPath - Ruta de acceso de nombres de imagen
string. Necesario cuando action == Tag images || action == Push images.

Especifica la ruta de acceso a un archivo de texto que contiene los nombres de las imágenes de Docker que se van a etiquetar o insertar. Enumere cada nombre de imagen en una línea independiente.


qualifyImageName - Nombre de la imagen apta
boolean. Opcional. Use cuando action = Build an image || action = Tag images || action = Push an image || action = Push images || action = Run an image. Valor predeterminado: true.

Especifica un nombre de imagen calificado con el nombre de host de la conexión del servicio del registro de Docker.


additionalImageTags - Etiquetas de imagen adicionales
string. Opcional. Use cuando action = Build an image || action = Tag images || action = Push an image || action = Push images.

Especifica etiquetas adicionales para la imagen de Docker que se está compilando o insertando.


includeSourceTags - Incluir etiquetas de origen
boolean. Opcional. Use cuando action = Build an image || action = Tag image || action = Push an image || action = Push images. Valor predeterminado: false.

Especifica si se deben incluir etiquetas de Git al compilar o insertar la imagen de Docker.


includeLatestTag - Incluir etiqueta más reciente
boolean. Opcional. Use cuando action = Build an image || action = Push an image || action = Push images. Valor predeterminado: false.

Especifica si se debe incluir la etiqueta más reciente al compilar o insertar la imagen de Docker.


imageDigestFile - Archivo de resumen de imagen
string. Opcional. Use cuando action = Push an image || action = Push images.

Especifica la ruta de acceso a un archivo que se crea y rellena con el resumen completo del repositorio de imágenes de la imagen de Docker que se insertó.


containerName - Nombre del contenedor
string. Opcional. Use cuando action = Run an image.

Especifica el nombre del contenedor de Docker que se va a ejecutar.


ports - Puertos
string. Opcional. Use cuando action = Run an image.

Especifica los puertos del contenedor de Docker que se van a publicar en el host. Enumere cada host-port:container-port enlace en una nueva línea.


volumes - Volúmenes
string. Opcional. Use cuando action = Run an image.

Especifica los volúmenes que se van a montar desde el host. Enumere cada una de ellas host-dir:container-dir en una nueva línea.


envVars - Variables de entorno
string. Opcional. Use cuando action = Run an image.

Especifica variables de entorno para el contenedor de Docker. Enumere cada name=value par en una nueva línea.


workDir - Directorio de trabajo
string. Opcional. Use cuando action = Run an image.

Especifica el directorio de trabajo para el contenedor de Docker.


entrypoint - Invalidación de punto de entrada
string. Opcional. Use cuando action = Run an image.

Especifica una invalidación del punto de entrada predeterminado para el contenedor de Docker.


containerCommand - Comando
string. Opcional. Use cuando action = Run an image.

Especifica un comando de ejecución de Docker. El comando docker run crea primero una capa de contenedor grabable sobre la imagen especificada y, a continuación, la inicia mediante el comando run especificado. Por ejemplo, si la imagen contiene una sencilla aplicación web de Python Flask, puede especificar python app.py para iniciar la aplicación web.


detached - Ejecutar en segundo plano
boolean. Opcional. Use cuando action = Run an image. Valor predeterminado: true.

Especifica si se va a ejecutar el contenedor de Docker en segundo plano.


restartPolicy - Reiniciar directiva
string. Necesario cuando action = Run an image && detached = true. Valores permitidos: no, onFailure (en caso de error), always, unlessStopped (a menos que se detenga). Valor predeterminado: no.

Especifica una directiva de reinicio.


restartMaxRetries - Número máximo de reintentos de reinicio
string. Opcional. Use cuando action = Run an image && detached = true && restartPolicy = onFailure.

Especifica el número máximo de reintentos de reinicio que intenta el demonio de Docker.


customCommand - Comando
string. Necesario cuando action = Run a Docker command.

Especifica el comando y los argumentos de Docker que se van a ejecutar. Por ejemplo, rmi -f image-name quita una imagen.


dockerHostEndpoint - Conexión de servicio de host de Docker
string.

Especifica una conexión de servicio de host de Docker. El valor predeterminado es el host del agente.


enforceDockerNamingConvention - Forzar el nombre de la imagen para seguir la convención de nomenclatura de Docker
boolean. Valor predeterminado: true.

Si está habilitado, modifica el nombre de la imagen de Docker según las convenciones de nomenclatura de Docker. Por ejemplo, convierta caracteres en mayúsculas en minúsculas y quite espacios.


workingDirectory - Directorio de trabajo
Alias de entrada: cwd. string. Valor predeterminado: $(System.DefaultWorkingDirectory).

Especifica el directorio de trabajo para el comando de Docker.


memory - Límite de memoria
string.

Especifica la cantidad máxima de memoria disponible para el contenedor como un entero con sufijos opcionales, por ejemplo 2GB.


Opciones de control de tareas

Todas las tareas tienen opciones de control además de las entradas de tareas. Para obtener más información, vea Opciones de control y propiedades de tareas comunes.

Variables de salida

Esta tarea define las siguientes variables de salida, que puede consumir en pasos, trabajos y fases de bajada.

DockerOutput
Almacena la salida del comando docker.

DockerOutputPath
Ruta de acceso del archivo que contiene la salida del comando de compilación.

Esta tarea define las siguientes variables de salida, que puede consumir en pasos, trabajos y fases de bajada.

DockerOutput
Almacena la salida del comando docker.

Comentarios

Docker@2 es una versión más reciente de esta tarea que simplifica la tarea quitando las entradas que se pueden pasar como argumentos al comando.

Requisitos

Requisito Descripción
Tipos de canalización YAML, compilación clásica, versión clásica
Se ejecuta en Agente, DeploymentGroup
Peticiones None
Capabilities Esta tarea no satisface ninguna demanda de tareas posteriores en el trabajo.
Restricciones de comandos Any
Variables que se pueden establecer Any
Versión del agente Todas las versiones de agente admitidas.
Categoría de la tarea: Build

Consulte también