The Docker Hub API allows for programmatic interaction with Docker Hub, enabling you to manage repositories, automate image builds, and work with webhooks and user accounts. On Pipedream, you can harness this API to create workflows that simplify and automate tasks like monitoring repository changes, triggering actions on image pushes, and orchestrating multi-service deployments.
import { axios } from "@pipedream/platform"
export default defineComponent({
props: {
docker_hub: {
type: "app",
app: "docker_hub",
}
},
async run({steps, $}) {
return await axios($, {
url: `https://hub.docker.com/v2/repositories/${this.docker_hub.$auth.username}`,
headers: {
Authorization: `Bearer ${this.docker_hub.$auth.oauth_access_token}`,
},
})
},
})
Automate Image Builds on Code Commit: Set up a workflow that watches for new commits on your GitHub repository and triggers a new image build on Docker Hub. This ensures your Docker images are always up-to-date with your latest code.
Monitor Docker Hub Repo for New Tags: Create a workflow that polls your Docker Hub repository for new tags and sends notifications via Slack or email. This can keep your team informed whenever a new version of your image is available.
Sync Docker Hub Repos with Cloud Storage: Develop a workflow that backs up new or updated images from your Docker Hub repository to cloud storage services like Google Drive or AWS S3, providing an extra layer of redundancy for your container images.
Docker Hub uses OAuth authentication. When you connect your Docker Hub account, Pipedream will open a popup window where you can sign into Docker Hub and grant Pipedream permission to connect to your account. Pipedream securely stores and automatically refreshes the OAuth tokens so you can easily authenticate any Docker Hub API.
Pipedream requests the following authorization scopes when you connect your account:
POST
https://hub.docker.com/v2/users/login
accept: application/json
username={{custom_fields.username}}
&
password={{custom_fields.personal_access_token}}
POST
https://hub.docker.com/v2/users/login
content-type: application/x-www-form-urlencoded
accept: application/json
username={{custom_fields.username}}
&
password={{custom_fields.personal_access_token}}