dockerdrone.io

Can't tag images on drone docker build: Error parsing reference: ":latest" is not a valid repository/tag: invalid reference format


I'm trying to use drone with gitlab. Before the step of pushing the docker image to my private registry, it raise an error:

Successfully built 7afb99118ae2
Successfully tagged ae872a846df0d8df884e89bd3a77cacf49b8f7de:latest
+ /usr/local/bin/docker tag ae872a846df0d8df884e89bd3a77cacf49b8f7de :latest
Error parsing reference: ":latest" is not a valid repository/tag: invalid reference format

My drone is drone/drone:1.0.0-rc.3

Here is my .drone.yml file

kind: pipeline
name: default

steps:
- name: build
  image: python:3.6
  commands:
  - pip install -r requirements.txt
  - python -m pytest app.py
  when:
    branch:
    - master
    event:
    - push
    - pull_request

- name: publish
  image: plugins/docker
  registry: registry.cn-beijing.aliyuncs.com
  repo: registry.cn-beijing.aliyuncs.com/xxx/xxx
  tags: latest
  username: 
  - from_secret: ali_username
  password:
  - from_secret: ali_password

And my Dockerfile

FROM python:3.6-alpine
RUN ln -snf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime && echo "Asia/Shanghai" > /etc/timezone
COPY requirements.txt /requirements.txt
RUN pip install -r /requirements.txt
ADD . /code
WORKDIR /code
CMD ["python", "app.py"]

I have tried like these:

tags: latest
tags: 1
tags: [1, 1.1]
tags: [1, 1.1, latest]
tags:
  - latest

And even delete tags row, but nothing worked.

What's wrong with it? Thanks for any tip!


Solution

  • Even it's in 2024,I got the same problem. The point is that drone cannot find the right "settings" so the repo name missed when building. We need put "settings" in the .drone.yml file. And it will be like:

    - name: build-image
      image: plugins/docker
      settings:
        username:
          from_secret: docker_username
        password:
          from_secret: docker_password
        dockerfile: ./Dockerfile
        repo: yourreponame/try-demo
        tags: latest