Docker Hub

Integrate DockerHub in Codefresh pipelines

To configure Docker Hub so that your pipelines can push images to it, first select Docker Hub from the new registry drop down and then provide the following:

  • Registry Name - a unique name for this configuration.
  • Username - Docker Hub username.
  • Password - Docker Hub personal account token or Dockerhub account password (not recommended)

Add Docker Hub Registry

Add Docker Hub Registry

Note that only allows you to push images that are tagged with your username. If you have a choice, create a Dockerhub account with the same username that you have in Codefresh. If not, you need to change the Docker image created to match your username in every push step.

If you have enabled two-factor-authentication in Dockerhub, then in the password field above you must put a Docker personal access token (instead of your Dockerhub master password). Otherwise Codefresh will not be able to push your image.

If you don’t have 2FA enabled in Dockerhub, then you can also use your Dockerhub account password. But in all cases we suggest you create a personal access token for Codefresh (personal access tokens are more secure as you can revoke them on demand and see when they were last used).

Adding more Dockerhub integrations

You can add additional Dockerhub accounts using the same process.

Additional Docker Hub integrations

Additional Docker Hub integrations

You can specify which registry will be used as primary/default for the domain. Use the appropriate registry name value in your pipelines in order to decide which Dockerhub account will be used.

Here is a pipeline that is pushing to two different Dockerhub accounts:

Pushing to multiple Dockerhub accounts

Pushing to multiple Dockerhub accounts

This is the respective pipeline definition:


version: "1.0"
  - "clone"
  - "build"
  - "push"

    title: "Cloning repository"
    type: "git-clone"
    repo: "kostis-codefresh/trivial-go-web"
    revision: "master"
    stage: "clone"
    title: "Building Docker image"
    type: "build"
    image_name: "trivial-go-web"
    working_directory: "${{clone}}"
    tag: "latest"
    dockerfile: "Dockerfile.multistage"
    stage: "build"
    disable_push: true
    title: "Pushing 1st Docker image"
    type: push
    image_name: "kostiscodefresh/trivial-go-web"
    tag: "latest"
    stage: "push" 
    registry: dockerhub
    candidate: ${{build}}
     title: "Pushing 2nd Docker image"
     type: push
     image_name: "kkapelon/trivial-go-web"
     tag: "latest"
     stage: "push" 
     registry: second-dockerhub
     candidate: ${{build}}

The two Dockerhub accounts are kkapelon and kostiscodefresh, and Codefresh is automatically using the correct integration by looking at the image_name property of the push step.