Search code examples
artifactorydocker-registryconcourse

Concourse unauthorized error pushing to Artifactory using docker-image-resource


I'm trying to use Concourse to grab a dockerfile defintion from a git repository, do some work, build the docker image, and push the new image to Artifactory. See below for the pipeline definition. At this time I have all stages up to the artifactory stage (the one that pushes to Artifactory) working. The artifactory stage exits with error with the following output:

waiting for docker to come up...
sha256:c6039bfb6ac572503c8d97f42b6a419b94139f37876ad331d03cb7c3e8811ff2
The push refers to repository [artifactory.server.com:2077/base/golang/alpine]
a4ab5bf94afd: Preparing
unauthorized: The client does not have permission to push to the repository.

This would seem straight-forward as an Artifactory permissions issue, except that I've tested locally with the docker cli and am able to push using the same user/pass as specified within destination_username and destination_password. I double checked the credentials to make sure I'm using the same ones and find that I am.

Question #1: is there any other known cause for getting this error? I've scoured the resource github page without finding anything. Any ideas why I may be getting the permissions error?

Without having an answer to the above question, I'd really like to dig deeper into troubleshooting the problem. To do so I use fly hijack to get a shell in the corresponding container. I notice that docker is installed on the container, so next step I think would be to do a docker import on the tarball for the image I'm trying to push and then perform a docker push to push it to the repo. When attempting to run the import I get the error:

Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?

Question #2: Why can't I use docker commands from within the container? Perhaps this has something to do with the issue I'm seeing with pushing to repo when running the pipeline (I don't think so)? Is it because the container isn't running with privilege? I thought that the privileged argument would be supplied in the resource type definition, but if not, how can I run with privilege?

resources:
- name: image-repo
  type: git
  source:
    branch: master
    private_key: ((private_key))
    uri: ssh://git@git-server/repo.git

- name: artifactory
  type: docker-image
  source:
    repository: artifactory.server.com:2077/((repo))
    tag: latest
    username: ((destination_username))
    password: ((destination_password))

jobs:
- name: update-image
  plan:
  - get: image-repo
  - task: do-stuff
    file: image-repo/scripts/do-stuff.yml
    vars:
      repository-directory: ((repo))
  - task: build-image
    privileged: true
    file: image-repo/scripts/build-image.yml
  - put: artifactory
    params:
      import_file: image/image.tar

Solution

  • Arghhhh. Found after much troubleshooting that the destination_password wasn't being picked up properly due to special characters and a lack of quotes. Fixed the issue by properly setting the password within yaml file being included with the --load-vars flag.