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.
- Create an Automated build: Add Automated Build
- Select the repository from github
- Change the namespace to
graze - Click
Create - Build Settings:
- Go to
Build Settings - Ensure that it is built on
tagandbranchandbranch = mastergets built aslatest
- Go to
- Create a build hook: This will build the image with extra arguments passed into the Dockerfile
- Create the file
hooks/build -
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" .
- Create the file
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.
- Create a standard repository: Add Repository
-
Push images to it using the
dockercommand 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.
- Go to
Collaborators - Add all the teams required for this project:
admin,owners=>Adminpermissiondevelopers,build,deploy=>Writepermission
README badges¶
You can include the image size and pulls on your README.md file using the following badges:
[](https://hub.docker.com/r/graze/skeleton-project/) [](https://hub.docker.com/r/graze/skeleton-project/)