3

I am trying to push a docker image into a private registry in Drone 0.8.5 and it works when I hardcode username and password into the pipeline however I have tried adding both the registry details in the registry tab and as secrets.

Registry Pipeline

docker-registry-push:
  image: plugins/docker
  repo: registry.domain.com:5000/app
  registry: registry.domain.com:5000
  insecure: true
  pull: true

Fails with no basic auth credentials

Finally I've tried variable substitution. (with $REGISTRY_USERNAME and $$REGISTRY_USERNAME variables. All result in a error msg="Error authenticating: exit status 1"

docker-registry-push:
  image: plugins/docker
  repo: registry.domain.com:5000/app
  registry: registry.domain.com:5000
  secrets:
    - source: registry_username
      target: username
    - source: registry_password
      target: password
  insecure: true
  pull: true

another attempt

docker-registry-push:
  image: plugins/docker
  repo: registry.domain.com:5000/app
  registry: registry.domain.com:5000
  username: ${REGISTRY_USERNAME}  
  password: ${REGISTRY_PASSWORD}
  secrets: [ registry_username, registry_password ]
  insecure: true
  pull: true

It is really frustrating. I need to add secrets for Rancher accesskey secretkey also after this via the correct method.

I have read other topics and the drone docs and am still stumped.

Thanks in advance.

DubC
  • 33
  • 4

2 Answers2

2

The secrets need to be injected into the docker container via the environment with the names docker_username and and docker_password.

Your .drone.yml file should look something like this:

pipeline:
  docker:
    image: plugins/docker
    repo: username/app
    registry: registry.domain.com:5000
    insecure: true
    pull: true
    secrets:
      - source: registry_username
        target: docker_username
      - source: registry_password
        target: docker_password

See the drone plugin docs for more configuration options.

Oliver
  • 11,857
  • 2
  • 36
  • 42
  • Ah ok - so I misread the plugin docs. That is working now. Thank-you so much. I really appreciate the helping hand guys!! – DubC Sep 11 '18 at 13:52
0

here is to manage drone secret key http://docs.drone.io/manage-secrets/#pull-requests

also, you might wanna consider using .netrc inside Dockerfile on your build, so your credential is embeded inside of your docker images

Fendi jatmiko
  • 2,567
  • 1
  • 9
  • 15