$ docker login
Login with your Docker ID to push and pull images from Docker Hub.
Username: DOCKER_HUB_USER_ID
Password: DOCKER_HUB_USER_PASSWORD
WARNING! Your password will be stored unencrypted in /home/USER_NAME/.docker/config.json.
Login Succeeded

$ cat ~/.docker/config.json
{
    "auths": {
        "https://index.docker.io/v1/": {
            "auth": "ZGV2b3BzYXdzbGludXg6VGhlamFhcnVuJCMyMQ=="
        }
    }
}

$ echo "ZGV2b3BzYXdzbGludXg6VGhlamFhcnVuJCMyMQ==" | base64 --decode
USER_NAME:PASSWORD                                                                              # credentials of DOCKER_HUB

then, base64 encode "~/.docker/config.json"
# COMMANDS:
$ cat ~/.docker/config.json | base64 -w0                                                        # (OR) 
$ cat ~/.docker/config.json | base64 -w 0                                                       # (OR)
$ echo $(cat /home/USER_NAME/.docker/config.json) | base64 -w 0                                 # (OR) 
$ echo $(cat ~/.docker/config.json) | base64 -w 0
# OUTPUT:
ewoJImF1dGhzIjogewoJCSJodHRwczovL2luZGV4LmRvY2tlci5pby92MS8iOiB7CgkJCSJhdXRoIjogIllYSjFiblJvWldwaE1qRTZRWEoxYm5Sb1pXcGhKQ015TVE9PSIKCQl9Cgl9Cn0=
The base64 encoding should appear on a single line so with -w0 we disable the wrapping.

$ docker logout
Removing login credentials for https://index.docker.io/v1/

$ cat ~/.docker/config.json
{
        "auths": {}
}
