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 textdocker login -u ... -p ... -e none ... succeeds and logs in~/.docker/config.jsonUsing Bamboo:
aws ecr get-login succeeds and returns the docker login command textdocker login -u ... -p ... -e none ... fails with the error abovechmod 777 ~/.docker/config.json makes no differenceBoth 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.
I had to remove my existing config.json file. It would not overwrite or modify the one that I had.
I found this question while trying to use ECR to get a Docker container running within a Jenkins pipeline on an AWS EC2 instance with an IAM Instance Profile. I found lots of information about creating, pushing, and pulling instances from ECR, but not running.
The goal is a Docker container with the specific Ruby and Ansible versions installed, with all the various dependencies like Gem files.
I found the following Jenkinsfile worked:
pipeline {
agent any
environment {
DOCKER_CONFIG = "${WORKSPACE}/docker.config"
}
stages {
stage('Build') {
steps {
sh("rm -rf ${DOCKER_CONFIG}")
sh("eval \$(aws ecr get-login --no-include-email | sed 's|https://||')")
withDockerContainer(args: '-v ${WORKSPACE}:/scripts -v ${HOME}/.aws:/root/.aws', image: 'image_name:latest') {
sh("ruby script.rb")
}
}
}
}
}
Notes:
You can remove the file docker-credential-osxkeychain:
$ sudo rm /usr/local/bin/docker-credential-osxkeychain