Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I get Docker for Windows to generate a plaintext auth key for access to private images on Docker Hub?

Amazon Elastic Beanstalk requires a plaintext key from Docker in order to access private images on Docker Hub. According to the instructions on AEB, you simply need to run docker login to generate these credentials in "%UserProfile%/.docker/config.json". However, this generates the following file:

{
    "auths": {
        "https://index.docker.io/v1/": {}
    },
    "HttpHeaders": {
        "User-Agent": "Docker-Client/17.12.0-ce (windows)"
    },
    "credsStore": "wincred"
}

The credentials were stored in "wincred", the windows credential manager.

How do I instead force the credentials to be generated, temporarily, within the config.json file instead?

like image 892
Casey Avatar asked Jan 28 '18 13:01

Casey


1 Answers

  1. Remove the last line from the "%UserProfile%/.docker/config.json" file:

(Don't forget to remove the trailing ',')

{
    "auths": {
        "https://index.docker.io/v1/": {}
    },
    "HttpHeaders": {
        "User-Agent": "Docker-Client/17.12.0-ce (windows)"
    }
}
  1. Save the config.json file.
  2. Run docker login.

If you look inside the config.json file, you will now find what you need. From what I understand, these credentials should be valid until either your username or password changes (you can see why it's good to have these in the credential manager!).

After you've copied out the auth key, you'll want to restore the config.json file to its original state:

{
    "auths": {
        "https://index.docker.io/v1/": {}
    },
    "HttpHeaders": {
        "User-Agent": "Docker-Client/17.12.0-ce (windows)"
    },
    "credsStore": "wincred"
}

Then run docker login once more to put things back how they originally were.

like image 86
Casey Avatar answered Oct 05 '22 23:10

Casey