Set up Docker Build Step in Bamboo - docker

I am currently despairing at the attempt of setting up a docker build step in Atlassian Bamboo.
For starters, I just want to create a build configuration that runs the hello-world image as a proof of confluence. So far, I have failed.
I have tried following the steps on https://confluence.atlassian.com/bamboo0609/using-bamboo/jobs-and-tasks/configuring-tasks/configuring-the-docker-task-in-bamboo , but to no avail.
My setup is this:
We have Bamboo installed on an Ubuntu server. I also installed Docker on that server and added the bamboo user to the docker usergroup and restarted the server to make sure the permission change takes effect. At this point, docker run hello-world works when I run it directly on the server. I can also confirm that this is the server that Bamboo runs on since Bamboo went offline whenever I restarted the server that I installed Docker on.
Then, I have added the docker capability to the server (the agent is the default agent, so it inherits this capability from the server). As the docker path, I have tried various things, none of which worked (aka, the following errors remained the same for each of these):
/snap/docker (the first folder that I found on a manual search)
/usr/bin/docker (the recommended path, though on inspecting the Ubuntu server I quickly found out that no docker folder exists under /usr/bin on the Ubuntu derver)
/var/snap/docker/common/var-lib-docker (the path that Docker returns as its Root Directory when I run docker info on the Ubuntu server)
/var/snap/docker (for good measure)
Now, for the runner, I have tried two different approaches.
First, I tried using a Docker runner with the following settings:
Command: Run a Docker container
Docker image: hello-world
This returns the following error message:
┊
Error occurred while running Task 'Hello World Docker Test(5)' of type com.atlassian.bamboo.plugins.bamboo-docker-plugin:task.docker.cli.com.atlassian.bamboo.task.TaskException: Failed to execute task
┊
Caused by: com.atlassian.bamboo.docker.DockerException: Error running Docker run command
┊
Caused by: com.atlassian.utils.process.ProcessException: Error executing /snap/docker run --volume /var/atlassian/application-data/bamboo/xml-data/build-dir/CAM-DOC-JOB1:/data --workdir /data --rm hello-world
┊
The second was just to run a shell runner for the command docker run hello-world, which returned the following error:
docker: not found
At this point, I feel like I'm out of ideas. Everything points towards Bamboo for some reason not finding Docker on the server, even though I can clearly confirm that it is there. I have tried various different approaches of telling Bamboo where to find Docker, but none of them have worked.
It's obvious that I'm doing something wrong, but I can't figure out what. Or maybe the problem lies in an entirely different direction altogether? Anyway, I would be grateful for any insight shared on this matter.

Okay, I found out what caused this strange behaviour.
The problem was that I installed Docker using sudo snap install docker, and apparently installing docker via snap causes problems with Bamboo.
So I got it to work using these simple steps:
[Server] Uninstalled Snap Docker using sudo snap remove docker
[Server] Reinstalled Docker using sudo apt install docker.io
[Bamboo] Changed the path to Docker in the Server Capabilities to /usr/bin/docker
After that, the hello-world image build succeeded and printed the expected output to the log.

Related

Docker/Ansible: ERROR! The playbook could not be found

I'm quite new to software development and having some issues setting up a docker container.
I've pull the docker container and run it. Now I want to apply some configuration to my container with
docker run --rm --network="ansible_default" -v C:\folder\folder1\ansible\playbooks:/ansible/playbooks docker.<address>/ansible ansible-playbook -i host localhost.playbook.yml
But when I run the above code, it just gives an error:
ERROR the playbook localhost.playbook.yml does not appear to be a file
I am running on administration powershell and have cd into the folder that contains the yaml files. (so inside C:\folder\folder1\ansible\playbooks)
Do I need ansible installed? Any pointers would be greatly appreciated!
EDIT: The docker container exits with a code 2, I'm supposed to be able to access it via localhost:8080 but it's just a blank screen. Exited(2) I'm not too sure what it means, haven't found much success online.
Turns out the solution is to reinstall Docker.

Docker Installation Problems

I'm new to using Docker (never used it before) and I'm running into these errors:
I installed the Docker for Windows and following the steps on this
tutorial, but Docker Desktop doesn't load up for me at all.
I tried to run the docker pull hello-world command but I'm getting the error: The system cannot find the file specified. In the default daemon configuration on Windows, the docker client must be run elevated to connect. This error may also indicate that the docker daemon is not running.
How do I fix this? Thanks

Gitlab-runner + Docker + Windows - Invalid volume specification

I'm trying to run my Gitlab CI locally using Gitlab-runner and docker before committing to make sure they work okay. But I'm having some strange issues!
Unfortunately I have no choice but to use windows (I've had success in the past on Linux).
Every time I run a job in powershell:
C:/Gitlab-runner/gitlab-runner exec docker npm
I get an error:
Job failed (system failure): Error response from daemon: invalid volume specification: '/host_mnt/c/builds/project-0/Users/Lewsmith/api:C:/Users/Lewsmith/api:ro' (executor_docker.go:921:0s)
I've tried setting docker volumes (nemerous combinations) and builds-dir:
C:/Gitlab-runner/gitlab-runner exec docker --builds-dir /builds --docker-privileged --docker-volumes "/builds:C:/Gitlab-runner/builds" npm
That fails with Error response from daemon: invalid mode: /Gitlab-runner/builds because of the colon after the C..
Can anyone point me in the right direction as I'm stumped?
Using gitlab-runner version 11.5.0
Docker is not fully supported by GitLab Runner on Windows yet.
The workaround is to use Windows Subsystem for Linux and install gitlab-runner there:
curl -L https://packages.gitlab.com/install/repositories/runner/gitlab-runner/script.deb.sh | sudo bash
sudo apt-get install gitlab-runner
gitlab-runner exec docker build
At the moment there isn't official support for the Docker executor in Windows. A work in progress issue is open at the moment, and it looks like some people have managed to get a windows docker executor working to varying success in that merge request.
This specific comment shows how they've managed to get it setup using a custom built gitlab-runner. I'm unsure how this will work with Services however, so YMMV.

Docker for Windows - Cannot run docker-compose up without getting "does not exist" or "login" errors

FYI - This all works when run on a Mac, but I am wanting to run on Windows.
I am running the following commands from IntelliJ terminal:
1 - docker login (logging in with my credentials and getting the success message)
2 - docker-compose up (to create and start the container)
However upon running the second command, I am greeted with:
Pulling marklogic (xxxxxxx:latest)...
ERROR: pull access denied for ..., repository does not exist or may require 'docker login'
I have searched the forums and found nothing to explain what is going wrong, other than my colleagues explanation that Windows is rubbish.
Any help would be appreciated.
Some extra info:
docker -v
Docker version 17.12.0-ce, build c97c6d6
docker-compose -v
docker-compose version 1.18.0, build 8dd22a96
Well pressassociation/faux-uds-marklogic isn't in DockerHub, so I guess you have to build that first yourself, or make sure your are pointing at an internal company repository that someone else has pushed the image to.
Perhaps it works on the Mac because a docker login has been made to an internal registry before running the docker-compose up ?
Do you use your own registry (docker-registry.xxx) in your project?

Running docker container on nanoPI leads to "exec format error"

The goal is to run docker containers on my nanoPI in the same manner as on a ubuntu server machine.
I have recently run into the following error when attempting docker run -it kylemanna/openvpn:
standard_init_linux.go:185: exec user process caused "exec format error"
I also get the same error when executing docker-compose using the container approach
Since I get the problem whether I use docker compose or not, I am starting to think that the error might be my usage of docker on the nanoPI. It may not be supported in the same way.
However, I can execute other containers/images just fine, hello-world, ubuntu, etc.
How do I go about determining the cause of this error? Where is the source code for standard_init_linux.go:185? And, what am I doing incorrectly?
Through trial and error, I discovered that if I rebuilt the openvpn image directly from the github repository on the machine with which the container would be run using (docker build <url>), then this error was resolved for the openvpn container but not (yet) for docker-compose. I imagine rebuilding the docker-compose container will fix the issue with that one too.
This is most likely due to a binary not having been compiled for the machine type that I was using.
Source/Inspiration: https://github.com/moby/moby/issues/23865

Resources