Skip to content

Docker Hub

Some projects include a Dockerfile that should be deployed to Docker Hub.

Docker Repositories

This can be deployed in a few ways, either automatically using an Automated Build on Docker Hub, or by using a Manual Build process to a Standard Repository.

Automated Build

Automated build repositories are useful when the build process is simple and everything can happen inside the Dockerfile.

The automated build, will automatically tag images for github branches with :branch-name and github tags with :tag. Commits pushed to master (or another chosen branch) to also become :latest.

  1. Create an Automated build: Add Automated Build
  2. Select the repository from github
  3. Change the namespace to graze
  4. Click Create
  5. Build Settings:
    1. Go to Build Settings
    2. Ensure that it is built on tag and branch and branch = master gets built as latest build settings
  6. Create a build hook: This will build the image with extra arguments passed into the Dockerfile
    1. Create the file hooks/build
    2. Put the following in:

      #!/bin/sh
      
      docker build --build-arg BUILD_DATE="$(date -u +"%Y-%m-%dT%H:%M:%SZ")" \
          --build-arg VCS_REF="$(git rev-parse --short HEAD)" \
          -t "$IMAGE_NAME" .
      

Manual Build

A manual build requires you to create a Standard Repository on Docker Hub.

You SHOULD include a specific tagged version when pushing, and manually specify the latest tag yourself only when appropriate.

  1. Create a standard repository: Add Repository
  2. Push images to it using the docker command line:

    docker login
    docker build --build-arg BUILD_DATE="$(date -u +"%Y-%m-%dT%H:%M:%SZ")" \
            --build-arg VCS_REF="$(git rev-parse --short HEAD)" \
            -t graze/skeleton:<tag> .
    docker push graze/skeleton:<tag>
    

Setting up Permissions

By default only the creator of a repository has access to it, so more permissions for your team are required.

  1. Go to Collaborators
  2. Add all the teams required for this project:
    1. admin,owners => Admin permission
    2. developers,build,deploy => Write permission

README badges

You can include the image size and pulls on your README.md file using the following badges:

[![Docker Image Size](https://img.shields.io/microbadger/image-size/graze/skeleton-project.svg?style=flat-square)](https://hub.docker.com/r/graze/skeleton-project/)
[![Docker Pulls](https://img.shields.io/docker/pulls/graze/skeleton-project.svg?style=flat-square)](https://hub.docker.com/r/graze/skeleton-project/)