Docker Login Current

I am trying to get docker login auth from ~/.docker/config.json file. But I do not see the auth token in my config.json file. Here is my version of docker.

 docker version Client: Version: 17.03.1-ce API version: 1.27 Go version: go1.7.5 Git commit: c6d412e Built: Tue Mar 28 00:40:02 2017 OS/Arch: darwin/amd64 Server: Version: 17.03.1-ce API version: 1.27 (minimum version 1.12) Go version: go1.7.5 Git commit: c6d412e Built: Fri Mar 24 00:00:50 2017 OS/Arch: linux/amd64 Experimental: true 

When I run cat ~/.docker/config.json , then I see

 cat .docker/config.json { "auths": { "https://index.docker.io/v1/": {} }, "credsStore": "osxkeychain" }% 

According to the Codex documentation I need to see

 { "auths": { "https://index.docker.io/v1/": { "auth": "auth_key", "email": "email" } } } 

Can I disable authkey in a keychain?

I really need to get auth_key , how can I get it?

thanks

+9
source share
4 answers

Auth is just a base64 encoded username: password string. You can get it with the following command:

 echo -n 'username:password' | base64 
+21
source

Using credential storage is safer than storing base64-encoded credentials in the config.json file. In your case, Docker uses the native Mac OS keychain (i.e. osxkeychain) as a credential store.

Now, to solve the problem of obtaining credentials from osxkeychain you can use docker-credential-helpers .

Steps to get credentials (in terminal):

  1. Download the latest version.
  2. Extract and move it to /usr/local/bin or add its path to $PATH . So you can access it all over the world.
  3. Run this command in terminal echo "<server-url>" | docker-credential-osxkeychain get echo "<server-url>" | docker-credential-osxkeychain get echo "<server-url>" | docker-credential-osxkeychain get echo "<server-url>" | docker-credential-osxkeychain get . If you want to know server-url use this command docker-credential-osxkeychain list .

Get credentials in Go code:

  package main

 import (
     "fmt"

     osx "github.com/docker/docker-credential-helpers/client"
 )

 func main () {

     p: = osx.NewShellProgramFunc ("docker-credential-osxkeychain")

     creds, err: = osx.Get (p, "server-url")
     if err! = nil {
         fmt.Println (err)
     }

     fmt.Printf ("Got credentials for user '% s' in '% s' with secret '% s' \ n", creds.Username, creds.ServerURL, creds.Secret)
 }
+5
source

using macos , you need to write a config.json file, such a template:

 { "auths": { "hub.xxx.com": { "username": "xxx", "password": "xxx", "email": "xxx", "auth": "base64(username:password)" } } } 
0
source

If you use Kuberentes, and you need it to create a registry password, just run:

 kubectl create secret docker-registry --dry-run=true docker-regcred \ --docker-server=https://index.docker.io/v1/ \ --docker-username=xxx \ --docker-password=xxx \ --docker-email=yourmail@yourdomain.com \ --namsepace yournamespace -o yaml > docker-secret.yaml 

This will create docker-secret.yaml with your JSON there. if you don't enable --dry-run and -o yaml> docker-secret.yaml then this will create a k8s secret.

0
source

Source: https://habr.com/ru/post/1266794/


All Articles