Skip to content

Instantly share code, notes, and snippets.

@flmu
Last active February 27, 2024 15:11
Show Gist options
  • Save flmu/59892c86673d3ab8f03fd6ac133120ee to your computer and use it in GitHub Desktop.
Save flmu/59892c86673d3ab8f03fd6ac133120ee to your computer and use it in GitHub Desktop.
Python example for using docker-credential-osxkeychain
#https://github.com/docker/docker-credential-helpers
import json
from subprocess import PIPE, STDOUT, Popen
keychain_cmd = ["docker-credential-osxkeychain", "get"]
p = Popen(keychain_cmd, stdout=PIPE, stdin=PIPE, stderr=STDOUT)
credentials_json, _ = p.communicate(input="#### auths name from .docker/config.json ####".encode('utf-8'))
credentials = json.loads(credentials_json.decode('utf-8'))
print(credentials['Username'], credentials['Secret'])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment