# Drone Docker build fails on tag

**URL:** <https://drone.discourse.group/t/drone-docker-build-fails-on-tag/10545>\
**Category:** Drone Support\
**Created:** [May 9, 2019, 2:51pm UTC](https://drone.discourse.group/t/drone-docker-build-fails-on-tag/10545 "2019-05-09T14:51:04Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![daniel](https://avatars.discourse-cdn.com/v4/letter/d/3ec8ea/32.png) [@daniel](https://drone.discourse.group/u/daniel)\
**Post date:** [May 9, 2019, 2:51pm UTC](https://drone.discourse.group/t/drone-docker-build-fails-on-tag/10545/1 "2019-05-09T14:51:04Z")

</div>

I’m using drone 1.1.0 with Gogs and have a definition like this:

```
kind: pipeline
name: default

- name: docker
  image: plugins/docker
  settings:
    username:
      from_secret: docker_username
    password:
      from_secret: docker_password
    target: production
    auto_tag: true
    repo:
      from_secret: docker_repo
    registry:
      from_secret: docker_registry

```

The build succeeds on a regular commit. But when I create a tag (e.g. 0.3) and push it, the build fails with the following message:

```
WARNING: bridge-nf-call-iptables is disabled
WARNING: bridge-nf-call-ip6tables is disabled
+ /usr/local/bin/docker build --rm=true -f Dockerfile -t . --pull=true --target production --label org.label-schema.schema-version=1.0 --label org.label-schema.build-date=2019-05-09T14:24:18Z --label org.label-schema.vcs-ref= --label org.label-schema.vcs-url=https://{redacted-server}/ ******** /drone-ci-test.git
invalid argument "" for "-t, --tag" flag: invalid reference format
See 'docker build --help'.
time="2019-05-09T14:24:18Z" level=fatal msg="exit status 125"

```

I get the same error when I omit `auto_tag: true`. Any ideas?

---

<div class="post-metadata">

**Author:** ![daniel](https://avatars.discourse-cdn.com/v4/letter/d/3ec8ea/32.png) [@daniel](https://drone.discourse.group/u/daniel)\
**Post date:** [May 10, 2019, 10:32am UTC](https://drone.discourse.group/t/drone-docker-build-fails-on-tag/10545/2 "2019-05-10T10:32:41Z")

</div>

I also tried to include `debug: true` which yields no additional info. Also: when I add

```
when:
  event: tag

```

and execute it locally with `drone exec` after I create a local git tag, the step is not executed.

---

<div class="post-metadata">

**Author:** ![atomi](https://yyz1.discourse-cdn.com/flex003/user_avatar/drone.discourse.group/atomi/32/4274_2.png) [@atomi](https://drone.discourse.group/u/atomi)\
**Post date:** [May 14, 2019, 2:33am UTC](https://drone.discourse.group/t/drone-docker-build-fails-on-tag/10545/3 "2019-05-14T02:33:48Z")

</div>

I can confirm this issue as well - same everything.

---

<div class="post-metadata">

**Author:** ![bradrydzewski](https://yyz1.discourse-cdn.com/flex003/user_avatar/drone.discourse.group/bradrydzewski/32/3513_2.png) [@bradrydzewski](https://drone.discourse.group/u/bradrydzewski)\
**Post date:** [May 14, 2019, 1:43pm UTC](https://drone.discourse.group/t/drone-docker-build-fails-on-tag/10545/4 "2019-05-14T13:43:03Z")

</div>

> [@On another topic](https://drone.discourse.group/t/4558/1):
>
> The build succeeds on a regular commit. But when I create a tag (e.g. 0.3) and push it, the build fails with the following message:

the `auto_tag` feature strictly requires semver. If you are no using semver you should manually specify the tag using the `tags` attribute in the yaml.

> [@On another topic](https://drone.discourse.group/t/4558/2):
>
> and execute it locally with `drone exec` after I create a local git tag, the step is not executed.

when you run `drone exec` locally you need to use the `--event` flag to tell drone which event to use. For example, `drone exec --event=tag`.

---

<div class="post-metadata">

**Author:** ![daniel](https://avatars.discourse-cdn.com/v4/letter/d/3ec8ea/32.png) [@daniel](https://drone.discourse.group/u/daniel)\
**Post date:** [May 14, 2019, 3:35pm UTC](https://drone.discourse.group/t/drone-docker-build-fails-on-tag/10545/5 "2019-05-14T15:35:25Z")

</div>

I tried to create a git tag with semantic versioning `0.3.0` and executed it locally with the `--event=tag` flag. Now my docker step gets executed, but it is just creating a `latest` tag with `auto_tag: true` in the repository. Only when I explicitly specify my version in `tags` and omit `auto_tag` the version is used. I also tried using `tags: ${DRONE_TAG}` which yields `Error parsing reference: " ******** :" is not a valid repository/tag: invalid reference format`.

---

<div class="post-metadata">

**Author:** ![bradrydzewski](https://yyz1.discourse-cdn.com/flex003/user_avatar/drone.discourse.group/bradrydzewski/32/3513_2.png) [@bradrydzewski](https://drone.discourse.group/u/bradrydzewski)\
**Post date:** [May 14, 2019, 3:51pm UTC](https://drone.discourse.group/t/drone-docker-build-fails-on-tag/10545/6 "2019-05-14T15:51:18Z")

</div>

I think there is an issue where Gogs does not work with autotag due to lack of commit sha being provided in the Gogs payload [1]. This may also impact Gitea since it is a fork of Gogs, although I think the Gitea folks patched this recently.

But otherwise, you will find that we use auto\_tag for Drone and all Drone plugins. Looking at some real-world configurations may be useful [2][3]

[1] [https://github.com/drone-plugins/drone-docker/issues/229](https://github.com/drone-plugins/drone-docker/issues/229)  
[2] [https://github.com/drone/drone/blob/master/.drone.yml](https://github.com/drone/drone/blob/master/.drone.yml)  
[3] [https://github.com/drone-plugins/drone-slack/blob/master/.drone.yml](https://github.com/drone-plugins/drone-slack/blob/master/.drone.yml)

---

<div class="post-metadata">

**Author:** ![atomi](https://yyz1.discourse-cdn.com/flex003/user_avatar/drone.discourse.group/atomi/32/4274_2.png) [@atomi](https://drone.discourse.group/u/atomi)\
**Post date:** [May 29, 2019, 1:16pm UTC](https://drone.discourse.group/t/drone-docker-build-fails-on-tag/10545/7 "2019-05-29T13:16:23Z")

</div>

FWIW I’ve switched to Gitea which works fine with tags.
