Last active
February 27, 2024 15:11
-
-
Save flmu/59892c86673d3ab8f03fd6ac133120ee to your computer and use it in GitHub Desktop.
Python example for using docker-credential-osxkeychain
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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