Bamboo "cannot connect to Docker daemon" - docker

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!

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>.

Related

How to execute a "docker run" command in circleci job

I need to add a circleCI job, after pulling a docker image (abc) i need to execute a "docker run" command on the container which is created by image abc to finish the job.
circleci_job:
docker:
- image: xyz.ecr.us-west-2.amazonaws.com/abc
steps:
- checkout
- run:
name: execute docker run command
command: |
export env1=https://example.com
docker run abc --some command
I am getting below error:
/bin/bash: line 1: docker: command not found
I wanted to know if i am using a wrong executer type ? or i am missing something here ?
I see two issues here.
You need to use an image that has the Docker client already installed or you need to install it on the fly in your job. Right now it appears that the image xyz.ecr.us-west-2.amazonaws.com/abc doesn't have Docker client installed.
With the Docker executor, in order for Docker commands such as docker run or docker pull to work, you need the special CircleCI step - setup_remote_docker to be run BEFORE you try using Docker.

docker image in gitlab CI used for create docker image

I want to build docker with "ready to run" application in docker CI, so to do that I have created in .gitlab-ci.yml this code:
rebuild base docker:
stage: prepear
image: docker
script:
- docker build -t base_django environment
I want to use the official docker image to do it (image: docker), of course in directory environment I have placed Dockerfile. Unfortunately job faild on:
Running with gitlab-runner 11.8.0 (4745a6f3)
on docker-auto-scale 72989761
Using Docker executor with image docker ...
Pulling docker image docker ...
Using docker image sha256:639de9917ae1f2e4a586893c9a6ea3f21fd774bc4037184ecac35f3153a293b5 for docker ...
Running on runner-72989761-project-9841176-concurrent-0 via runner-72989761-srm-1552402128-c63119b1...
Cloning repository...
Cloning into '/builds/*****/*****'...
Checking out a804a12f as master...
Skipping Git submodules setup
$ docker build -t base_django environment
Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?
ERROR: Job failed: exit code 1
You need a specific configuration to run docker in docker with Gitlab CI. You can find more information right here : https://docs.gitlab.com/ee/ci/docker/using_docker_build.html

What is the correct upload URL for a Dockerhub repo

I am following the instructions for the custom-vision service on raspberry-pi on IOT edge.
I have reached step 3, where in VS Code I am executing Build and Push to IOT Edge Solution and this is triggering the following command:
docker build --rm -f "/Users/myname/Dropbox/Dev/azure/custom-vision/Custom-vision-service-iot-edge-raspberry-pi/modules/CameraCapture/arm32v7.Dockerfile" -t registry.hub.docker.com/v1/repositories/myname/iot-hub-1/cameracapture:0.2.7-arm32v7 "/Users/myname/Dropbox/Dev/azure/custom-vision/Custom-vision-service-iot-edge-raspberry-pi/modules/CameraCapture"
&& docker push registry.hub.docker.com/v1/repositories/myname/iot-hub-1/cameracapture:0.2.7-arm32v7
&& docker build --rm -f "/Users/myname/Dropbox/Dev/azure/custom-vision/Custom-vision-service-iot-edge-raspberry-pi/modules/ImageClassifierService/arm32v7.Dockerfile" -t registry.hub.docker.com/v1/repositories/myname/iot-hub-1/imageclassifierservice:0.2.4-arm32v7 "/Users/myname/Dropbox/Dev/azure/custom-vision/Custom-vision-service-iot-edge-raspberry-pi/modules/ImageClassifierService"
&& docker push registry.hub.docker.com/v1/repositories/myname/iot-hub-1/imageclassifierservice:0.2.4-arm32v7
Which is failing with 404 - page not found.
I also tried using cloud.docker.com/repository/registry-1.docker.io/myname/iot-hub-1 but this gave me a different error:
invalid argument
"cloud.docker.com/repository/docker/myname/iot-hub-1:latest/cameracapture:0.2.7-arm32v7"
for "-t, --tag" flag: invalid reference format
Can anyone assist with the correct URL path, or some the additional steps i need to uploading the containers to my docker hub repository?
I couldn't find the correct URL for dockerhub, but Azure Container Registry was able to resolve my problem.
Details of the URL are here: Raspberry PI / IOTEdge failing to pull from Azure Container Registry
You need docker login first. Then build image docker build -t <docker_hub_username>/<app_name>:<tag> and then just push docker push <docker_hub_username>/<app_name>:<tag>. You don't need to specify any specific URL for Docker Hub.
Use this:
docker push <hub-user>/<repo-name>:<tag>
i.e
docker push username/reponame:latest

Jenkins docker setup

I am using Jenkins to make build of project, but now my client wants to make builds inside of a Docker image. i have installed docker on server and its running on 172.0.0.1:PORT. I have installed Docker plugin and assigned this TCP URL to Docker URL. I have also created an image with the name jenkins-1
In configure project I use Build environment Build with Docker Container and provide image name. and then in Build in put Execute Shell and then Build it
But it gives the Error:
Pull Docker image jenkins-1 from repository ...`
$ docker pull jenkins-1`
Failed to pull Docker image jenkins-1`
FATAL: Failed to pull Docker image jenkins-1`
java.io.IOException: Failed to pull Docker image jenkins-1``
at com.cloudbees.jenkins.plugins.docker_build_env.PullDockerImageSelector.prepare DockerImage(PullDockerImageSelector.java:34)`
at com.cloudbees.jenkins.plugins.docker_build_env.DockerBuildWrapper.setUp(DockerB`uildWrapper.java:169)`
at hudson.model.Build$BuildExecution.doRun(Build.java:156)`
at `hudson.model.AbstractBuild$AbstractBuildExecution.run(AbstractBuild.java:534)`
at hudson.model.Run.execute(Run.java:1720)`
at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:43)`
at hudson.model.ResourceController.execute(ResourceController.java:98)`
at hudson.model.Executor.run(Executor.java:404)`
Finished: FAILURE`
I just have run into the same issue. There is a 'Verbose' check-box in the configuration of build environment after selecting 'Advanced...' link to expand on the error details:
CloudBees plug-in Verbose option
In my case I ran out of space downloading the build Docker images. Expanding ec2 volume has resolved the issue.
But there is an ongoing trouble with space as docker does not auto cleans images and I have ended up adding a manual cleanup step into the build:
docker volume ls -qf dangling=true | xargs -r docker volume rm
Complete build script:
https://bitbucket.org/vk-smith/dotnetcore-api/src/master/ci-build.sh?fileviewer=file-view-default

Unable to start Docker Container in Bluemix

I have created a simple docker file to deploy a war in tomcat
FROM tomcat
ADD your.war /usr/local/tomcat/webapps/
CMD ["catalina.sh", "run"]
I tested locally and works. I tried building the image and pushed it to Bluemix. The docker image got pushed and I can see it in the dashboard, but while trying to start it up (By Clicking on it ), the Vulnerability assessment kicks off and it gives a warning symbol with an Incomplete text and I am unable to proceed further. Need pointers on how to go about this.
Steps followed -
From my local m/c where I have docker running
# docker tag testimagetom registry.ng.bluemix.net/shabsctr/testimagetom:image_tag
# docker push registry.ng.bluemix.net/shabsctr/testimagetom:image_tag
# cf ic run --name shabstrydocker registry.ng.bluemix.net/shabsctr/testimagetom:image_tag
You can build images with DockerFile by cf command. It'll create your image on your bluemix registory.
cf ic build [--tag|-t TAG_NAME] [--no-cache] [--pull] [--quiet] LOCAL_DOCKER_FILE_PATH

Resources