ACCESS: How to configure Artifactory access token in .docker/config.json for preloaded authentication

AuthorFullName__c
Elumalai Ganesan
articleNumber
000006070
FirstPublishedDate
2024-04-17T06:38:36Z
lastModifiedDate
2025-07-22

ACCESS: How to configure Artifactory access token in .docker/config.json for preloaded authentication

Docker stores the authentication details for the users in their corresponding /$user/.docker/config.json file. Docker also stores these credentials after converting the keypair “username:accesstoken” and “username:password” to base64 encryption.

In-order to store the credentials (keypair) in your /$user/.docker/config.json file. Please follow the below steps:

  1. Create an access token by navigating to Administration → User Management → Access Token → Generate New Token. Please find the screenshot below:

User-added image

Note: In the above screenshot, I have set the username as a demo.


2. Once the token is generated, the next step will be converting the keypair “demo:accesstoken” to base64 by making use of the below command.
echo -n '$username:95UKh5t79NQ' | base64
3. Now, we have the converted base64 string which can be used in the /$user/.docker/config.json file. Please find the sample format for your reference:
{
    "auths": {
        "localhost:8082": {
            "auth": "aUppT0dJd016TmhZaTFqTkRZeExUUXlObUl0WW1SbE9TMWhNR1l6TWpsbU9XUTVObU1pZlEuRElYSVRELWVjc…………..bHZ5aGdFZVNzYldjV………………..eXdrR3VTeEdFNGFjdDk1VUtoNXQ3OU5R"
        }
    }
}

4. Once the config.json file is set up, we can proceed further with the docker login hostname and it will authenticate with the preloaded credentials.


Please find the snippet for your reference:

[root@root .docker]# docker login localhost:8082
Authenticating with existing credentials...
WARNING! Your password will be stored unencrypted in /root/.docker/config.json.
Configure a credential helper to remove this warning. See
https://docs.docker.com/engine/reference/commandline/login/#credentials-store

Login Succeeded


Note: If you perform a docker logout the credentials will be revoked from the /$user/.docker/config.json file.