Skip to content

Instantly share code, notes, and snippets.

@ajorpheus
Created August 24, 2021 09:41
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ajorpheus/fb33faeda49ce58284920243ac3add7f to your computer and use it in GitHub Desktop.
Save ajorpheus/fb33faeda49ce58284920243ac3add7f to your computer and use it in GitHub Desktop.
Create a repository on Docker Hub from CLI
#!/usr/bin/env bash
export USER="johndoe"
export PASS="personal-access-token"
## Get the JWT token
TOKEN=$(curl -s -H "Content-Type: application/json" -X POST -d '{"username": "'${USER}'", "password": "'${PASS}'"}' https://hub.docker.com/v2/users/login/ | jq -r .token)
## API call to create repo
curl -s -H "Authorization: JWT ${TOKEN}" "https://hub.docker.com/v2/repositories/" --data 'description=test' --data 'full_description=full-description' --data 'is_private=true' --data 'name=test' --data "namespace=${USER}"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment