Gitlab-runner + Docker + Windows - Invalid volume specification - docker

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.

Related

Not able to connect to a docker container from windows using io.fabric8

I am running some Integration tests on a Windows 10 machine. I have a Java maven project that uses io.fabric8 docker maven plugin to manage docker images and containers.
I am having issues when my Integration Tests are trying to communicate with docker container.
I'm seeing the following error:
Failed to execute goal io.fabric8:docker-maven-plugin:0.19.0:start (prepare-it) on project some-app-name: Execution prepare-it of goal io.fabric8:docker-maven-plugin:0.19.0:start failed: Start-Job failed with unexpected exception: [rabbitmq:3-management-alpine] "rabbitmq": Timeout after 55148 ms while waiting on url http://127.0.0.1:65474 -> [Help 1]
I've tried running it with
mvn clean install -Dlocal.host=0.0.0.0 and mvn clean install -Dlocal.host=127.0.0.1 with no luck. Similiar error message as above.
My windows 10 environment variable is:
DOCKER_HOST env variable is set to tcp://username-remotelinux.somecloudprovider.co.uk:2375
When I run docker ps, I see the following:
$ docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
34b43c52ca96 rabbitmq:3-management-alpine "docker-entrypoint.s…" 13 seconds ago Up 11 seconds 4369/tcp, 5671/tcp, 0.0.0.0:5672->5672/tcp, 15671/tcp, 25672/tcp, 0.0.0.0:15672->15672/tcp docker_rabbitmq_1
I also checked the IP address of the container:
$ docker inspect -f '{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' c6314df1cd10
172.24.0.5
I've noticed that the ip address of the container is different to what I see when I run docker ps.
Is there a reason why its different?
How do I get this to work? Any ideas?
UPDATE 1:
I've also tried using 0.33.0 version of the docker maven plugin with no luck. I'm getting the same error as above
UPDATE 2:
I've also tried running with mvn install -Ddocker.host=tcp://username-remotelinux.somecloudprovider.co.uk:2375 with no luck. There must be something I'm missing. How to get maven to table to remote docker

Set up Docker Build Step in Bamboo

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.

Input file not found in docker command on windows

Complete docker noob here, i installed docker desktop on windows - Trying to follow the commands on this link to setup OSRM backend on my machine. i've downloaded the dataset for india(india-latest.osm.pbf) to D:/docker
and am running the commands from that location
docker run -t -v "${PWD}:/data" osrm/osrm-backend osrm-extract -p /opt/car.lua /data/india-latest.osm.pbf
fails with
[error] Input file /data/india-latest.osm.pbf not found!
i just don't understand WHY it doesn't work. according to osrm documentation of the docker command -
The file /data/india-latest.osm.pbf inside the container is referring
to "${PWD}/india-latest.osm.pbf" on the host.
but it's not the case,i am running from d:/docker so it should find india-latest.osm.pbf no problem. This is really really confusing to me even though it must be so basic
it was due to a bug in docker https://github.com/docker/for-win/issues/1712
when you change password it silently fails for commands that access the host filesystem on windows until you reauthenticate

Change/Degrade Docker API version

Need some serious help, I have installed docker on ubuntu18.04, and also tested through command 'docker run hello-world', it ran successfully. Now when I run 'docker compose up -d', it says
'Error :Couldn't connect to docker daemon.You may need to create docker-machine start default'.
Also when checked error through docker --verbose it says
'Error:Bad Request : Client API version is too new 1.36 -Maximum supported API version is 1.35'.
that's the case then how can I upgrade the API-version in for docker? My docker version is 17.12.
Plz check if you are running the correct command, it is:
docker-compose up -d
you are missing a "-"

CI & Docker-in-a-Docker

I am trying to integrate docker into my CI platform. After getting this working properly with a Docker-in-a-docker solution, I came across a blog post by one of the Docker maintainers, where he says that instead of using a Docker-in-a-docker solution for my CI, I should instead simply mount the /var/run/docker.sock to my CI container.
https://jpetazzo.github.io/2015/09/03/do-not-use-docker-in-docker-for-ci/
Simply put, when you start your CI container (Jenkins or other), instead of hacking something together with Docker-in-Docker, start it with:
docker run -v /var/run/docker.sock:/var/run/docker.sock ...
So I tried this. I ran the following command:
docker run -p 8080:8080 -p 50000:50000 -v /var/run/docker.sock:/var/run/docker.sock jenkins
Using jenkins as my CI container.
When running the above command, jenkins starts up properly, and I can jump into the container to see that the docker.sock file is located in the /var/run/ path.
However, when I run the command: docker, the machine returns with the following message:
bash: docker: command not found
Does anyone know what I am missing in order to make this work per the author's instructions?
I am using Docker v. 1.11.1, on a fresh CentOS 7 box.
Thanks in advance
Figured this out today. The above command will work so long as the docker daemon + dependencies are added to the container. In my case, I ended up writing a simple Dockerfile, which also included the line:
RUN curl -sSL https://get.docker.com/ | sh
This installed Docker on the container, and when I ran docker images from within the container, I could see all of the images from my host machine. I am now able to use all of the docker commands from within the container.

Resources