Docker Hub Authentication With Orb Executors

At the moment, unless an Orb has been specifically updated, it is not possible to pass Docker Hub auth parameters to the executors defined by an orb. This is something CircleCI is looking into, as well as evaluating our partnership with Docker regarding rate limiting in general.

The general consensus is that each orb will need to be updated to allow the docker auth parameters to be passed - please feel free to raise an issue against the GitHub repos to bring this up with the Community team directly.

The best workaround for this right now is to define the executor manually.

 

Let's take a look at an example by using the cimg/php image:

 

If we look at the source for the executor is it simply:

description: The official CircleCI CIMG PHP Docker image.
docker:
- image: 'cimg/php:<< parameters.tag >>'
parameters:
tag:
default: '7.4'
description: The `cimg/php` Docker image version tag.
type: string

This executor definition in the orb isn't doing much more than spinning up a docker image defined by a parameter. This means you can implement this executor yourself in your config.yml. The below example is based on the example shown in the Docker private images guide:

version: 2.1

workflows:
my-workflow:
jobs:
- build:
context:
- build-env-vars
- docker-hub-creds

jobs:
build:
docker:
- image: cimg/php:7.4
auth:
username: mydockerhub-user # can specify string literal values
password: $DOCKERHUB_PASSWORD # or project environment variable reference

Or, if you want to retain the parameter functionality instead of hard-coding the version, you can add this as follows:

version: 2.1

workflows:
my-workflow:
jobs:
- build:
phpver: "7.3.11"
context:
- build-env-vars
- docker-hub-creds

jobs:
build:
parameters:
phpver:
type: string
default: "7.4"
docker:
- image: cimg/php:<< parameters.phpver>>
auth:
username: mydockerhub-user # can specify string literal values
password: $DOCKERHUB_PASSWORD # or project environment variable reference
steps:
- run: echo "Hello!"

 

Was this article helpful?
1 out of 2 found this helpful

Comments

0 comments

Article is closed for comments.