Support tag not semantic version when using docker plugin auto_tag

Hi, all

I use plugins/docker to build docker image, but i found the image the final tag is 0.1.0-alpha1 when my tag like v0.1.0-alpha1, i hope the docker plugin use v0.1.0-alpha1 as image tag.

I don’t know why the docker plugin not support it, because i remember plugin support it before. Maybe i missing something, so if someone know, hope can tell me. Thanks.

auto-tagging strips the “v” from the tag prefix.

Yes, i see the docker plugin code, it use semantic version.
I use tags parameter, like this tags: [ "${DRONE_TAG}" ], the docker plugin not works. But when i add debug: true, it works. I don’t know why.

If you are using auto_tag you should not be settings tags manually.

Here is an example of how we use auto_tag for drone https://github.com/drone/drone/blob/master/.drone.yml#L32:L46

Thanks, I remove tags and only use auto_tag, it’s OK. if my tag is v0.1.0, the image tag is 0.1.0, but I hope the image tag is the same as git tag, so I try the tags, but if I not set debug, it’s not work.

auto-tag is very opinionated and uses best practices for tagging images, based on how the official dockerhub images are tagged. Auto-tag therefore may not be a good fit for every project.

auto-tag is good, but i have some project use not semantic version use as git tag, so i can’t use this configuration, i have to use tags instead of auto_tag, but when i use tags, it not work.

- name: build
  image: docker.cloud/plugins/docker
  settings:
    dockerfile: Dockerfile
    force_tag: true
    insecure: true
    password:
      from_secret: docker_password
    registry: docker.cloud
    repo: docker.cloud/kubernetes/node-pool-operator
    tags:
    - "${DRONE_TAG}"
    username:
      from_secret: docker_username
  privileged: true
  when:
    event:
    - tag

If i want this pipeline works, i must setting debug: true in settings, i don’t know where is wrong. Can you tell me if you have time?

I also can’t get regular tags to work with this. @bradrydzewski I assume you are busy, but would you know why?

Snippet:

- name: deploy-tag
    image: plugins/docker
    settings:
      tags:
        - ${DRONE_TAG}
      repo: otomi/nodejs-helloworld
      username:
        from_secret: REGISTRY_USERNAME
      password:
        from_secret: REGISTRY_PASSWORD
      target: prod
      cache_from:
        - otomi/nodejs-helloworld:master
    when:
      event:
        - tag

I do not have enough detail to advise why it would not be working for you, however, I setup a simple yaml [1] that defines tags and then I ran the build [2] and it used the tags as expected. Manually defining tags in the yaml is a widely used feature – most projects do not use autotag.

Here is the sample yaml that defines the tags:

kind: pipeline
type: docker
name: default

steps:
  - name: build
    image: plugins/docker
    pull: if-not-exists
    settings:
      dry_run: true
      repo: foo/bar
      tags:
      - latest
      - ${DRONE_BRANCH}

And if you look at the logs [2] you can see that it tags the image accordingly:

+ docker tag d4b8902ca3fc12b4b48fbd3e9dcd267c357aa92b foo/bar:latest
+ docker tag d4b8902ca3fc12b4b48fbd3e9dcd267c357aa92b foo/bar:master

[1] https://github.com/drone/hello-world/blob/docker-example/.drone.yml
[2] https://cloud.drone.io/drone/hello-world/204/1/2