BoltzmannBrain
BoltzmannBrain

Reputation: 5392

Bamboo "cannot connect to Docker daemon"

My Bamboo build plan (running on an linux64 agent) has a stage to do a source code checkout from my GitHub repo, and then a stage to build an image with that Dockerfile, which looks like this:

set -o xtrace
set -o errexit
${bamboo_DOCKER_SIGNATURE} build ${bamboo_DOCKER_BUILD_EXTRAS} -t myname:${bamboo_buildNumber} -f Dockerfile .

The next stage I want is a script that pushes this image to my Docker registry (on Quay.io). The script I have so far is below, but the build fails with the error "Cannot connect to the Docker daemon. Is the docker daemon running on this host?".

set -o xtrace
set -o errexit

# service docker start  # commented out b/c this did not solve the docker daemon issue

# This is where the build fails:
docker login -e="." -u=${bamboo.QUAY_ROBOT_name} -p=${bamboo.QUAY_ROBOT_token} quay.io

# Push the image to 'my_repo' in the Quay.io organization 'my_team', with tag 'bamboo_build'
docker push quay.io/my_team/my_repo:bamboo_build${bamboo_buildNumber}

FWIW the same login command works as expected from my local command line. How can I remedy this? Also, using Bamboo's built in Docker task does not work -- it's unable to login to the registry, but for some reason does not have the "docker daemon" issue. Thank you in advance for any help!

Upvotes: 3

Views: 711

Answers (1)

BoltzmannBrain
BoltzmannBrain

Reputation: 5392

The trick was to use the Bamboo variable ${bamboo_DOCKER_SIGNATURE} instead of docker. This variable says to use a specific host--i.e., docker -H <host address>.

Upvotes: 1

Related Questions