Skip to content

[BUG]: Docker@1 - Docker v1 Tag image command retags existing image #21974

@igorpupkinable

Description

@igorpupkinable

New issue checklist

Task name

Docker

Task version

1.269.1

Issue Description

Docker@1 task re-tags existing image due to a missing check.

The fix:
Check if sourceImageName === targetImageName before creating promise, i.e.

let promise;

if (firstMapping.sourceImageName === firstMapping.targetImageName) {
  // Do not invoke docker tag if tags match
  promise = Promise.resolve(not sure what is should resolve with);
} else {
  promise = dockerTag(connection, firstMapping.sourceImageName, firstMapping.targetImageName, qualifyImageName, qualifySourceImageName);
}

Environment type (Please select at least one enviroment where you face this issue)

  • Self-Hosted
  • Microsoft Hosted
  • VMSS Pool
  • Container

Azure DevOps Server type

dev.azure.com (formerly visualstudio.com)

Azure DevOps Server Version (if applicable)

No response

Operation system

Ubuntu 22.04

Relevant log output

Starting: Tag image
==============================================================================
Task         : Docker
Description  : Build, tag, push, or run Docker images, or run a Docker command
Version      : 1.269.1
Author       : Microsoft Corporation
Help         : https://docs.microsoft.com/azure/devops/pipelines/tasks/build/docker
==============================================================================
/usr/bin/docker tag [REDACTED]/repo/image:example-tag [REDACTED]/repo/image:example-tag

> NOTE:
> docker tag is called once without any task arguments or called twice *with* task arguments
> docker tag should be called just once with *task* arguments and not invoked at all if tags match

Finishing: Tag image

Full task logs with system.debug enabled

Please see log output above.

Repro steps

- task: Docker@1
  displayName: Tag image
    inputs:
      #arguments: latest <= uncommenting this line should call `docker tag` once, not twice
      azureContainerRegistry: $([REDACTED])
      azureSubscriptionEndpoint: $([REDACTED])
      command: 'Tag image'
      containerregistrytype: 'Azure Container Registry'
      imageName: $(imageRepository):example-tag
      qualifySourceImageName: true

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions