docker icon indicating copy to clipboard operation
docker copied to clipboard

jenkins container can't execute git command in windows jenkins_home directory

Open gis2all opened this issue 4 years ago • 4 comments

I start jenkins container in Docker Desktop (windows) , use windows host F:\Data\Docker\jenkins\jenkins_home as jenkins home directory

docker run ^
 --name jenkins ^
 -p 8080:8080 -p 50000:50000 ^
 -v F:\Data\Docker\jenkins\jenkins_home:/var/jenkins_home ^
 -v //var/run/docker.sock:/var/run/docker.sock ^
 jenkins-jdk11-docker:latest

jenkins-jdk11-docker:latest is my image based on official image https://www.jenkins.io/doc/book/installing/docker/

I use SCM pipeline to config my job,

image

The problem is jenkins container is linux system and its default git tool is /var/lib/git , every time jenkins instance clone my jenkinfile repo and actually the git will execute command in windows directory F:\Data\Docker\jenkins\jenkins_home , this will failed to execute

So can I use such like -v "C:\Program Files\Git\bin\git.exe":/var/lib/git parameter to replace default linux git tool with windows git tool , I try this but failed, or any better way to solve the issue?

gis2all avatar Aug 08 '21 11:08 gis2all

Are you using a windows container like https://hub.docker.com/layers/jenkins/jenkins/jdk11-hotspot-windowsservercore-2019/images/sha256-ff04982cb7533b1930ffec2fa9964a291acc5aac7e88087c3eed28877991580a?context=repo ?

or a linux container?

timja avatar Aug 08 '21 11:08 timja

Are you using a windows container like https://hub.docker.com/layers/jenkins/jenkins/jdk11-hotspot-windowsservercore-2019/images/sha256-ff04982cb7533b1930ffec2fa9964a291acc5aac7e88087c3eed28877991580a?context=repo ?

or a linux container?

Hi @timja my container is a linux container, and this jenkins container will install another docker, refer the content about windows in this doc https://www.jenkins.io/doc/book/installing/docker/ . My Dockerfile as below

FROM jenkins/jenkins:lts-jdk11
USER root
RUN	apt-get update && \
	apt-get -y install apt-transport-https \
	  ca-certificates \
	  curl \
	  gnupg2 \
	  software-properties-common && \
	curl -fsSL https://download.docker.com/linux/$(. /etc/os-release; echo "$ID")/gpg > /tmp/dkey; apt-key add /tmp/dkey && \
	add-apt-repository \
	  "deb [arch=amd64] https://download.docker.com/linux/$(. /etc/os-release; echo "$ID") \
	  $(lsb_release -cs) \
	  stable" && \
	apt-get update && \
	apt-get -y install docker-ce
docker build -t jenkins-jdk11-docker:latest .

if I don't config my job with SCM pipeline, all things are going well 😦

gis2all avatar Aug 08 '21 11:08 gis2all

That page looks out of date, we do supply windows controller images, cc @MarkEWaite.

Can you use that instead? I think you wouldn't have the git issue anymore then

timja avatar Aug 08 '21 11:08 timja

thanks ! I will try it

gis2all avatar Aug 08 '21 11:08 gis2all