Question: I am running a `docker login` command as a part of the Bamboo build job. The command text is obtained by `aws ecr get-login` call and executed in a subshell.

This command fails with `Error saving credentials: error storing credentials - err: exit status 1, out: write permissions error` when ran as a part of the Bamboo build, but the exact same command ran in the Terminal on the Mac that is the build agent, it succeeds.

Using Terminal:

* `aws ecr get-login` succeeds and returns the `docker login` command text
* `docker login -u ... -p ... -e none ...` succeeds and logs in
* There is a record for the ECR URL in KeyChain
* There is an entry in `~/.docker/config.json`

Using Bamboo:

* `aws ecr get-login` succeeds and returns the `docker login` command text
* `docker login -u ... -p ... -e none ...` fails with the error above
* KeyChain record being made available to all applications makes no difference'
* `chmod 777 ~/.docker/config.json` makes no difference

Both the Bamboo build and the Terminal session happen under the same user - `builduser`. `whoami` is the same for both. `stat ~/.docker/config.json` is the same for both - writable for both.

Can you think of further ways of discovering the differences between the context Bamboo runs the build in and I do in the terminal? The error above, verbatim, related to `docker login` is nowhere to be found online.

Answer: 
Install the following package then try docker login again
`sudo apt install install gnupg2 pass`

If it still doesn't work, run the command with root privileges
`sudo docker login`
For me the simplest solution was to create config.json file under .docker directory inside the user home directory:

~/home/.docker/config.json

Then I copied the content of this file from the server from where i was able to login to the docker hub.

```
{
        "auths": {
                "https://index.docker.io/v1/": {
                        "auth": "SOMEVALUE"
                }
        },
        "HttpHeaders": {
                "User-Agent": "Docker-Client/18.06.1-ce (linux)"
        }

}

```