0

How to access and execute local system folders/files in jenkins when jenkins image is installed in docker desktop container?

Please help me to find a way by which we can access and execute local files/folders, inside jenkins image available in docker desktop container?

For example: How to access and run cypress project with jenkins, when the cypress project is available in our local system : For this I've tried by providing custom workspace directory path but also I am getting below errors and not able to run it via jenkins.

  • I've also observed that while providing path to custom workspace directory If I use 'Users/...' (i.e not used forward slash at starting) then I am getting below error:

SC Ref. 1: Custom Workspace path without forward slash at starting

Console output error for Custom Workspace path without forward slash at starting)

  • But while providing path to custom workspace directory If I use '/Users/...' (i.e used forward slash at starting) then I am getting below error:

SC Ref. 2: Custom Workspace path with forward slash at starting

Console output error for Custom Workspace path with forward slash at starting

For ref.: Installed jenkins image container details: Installed jenkins image container details

Thanks for your help in advance!

TechTalk
  • 1
  • 1
  • How are you running Jenkins? Are you using a docker command to run the docker image? – Atxulo Jan 31 '23 at 14:02
  • Yes @Atxulo, I am using 'docker start ContainerID' to start jenkins container... Alternatively as I am using Docker Desktop so directly by clicking on play/Start button available on UI of docker desktop I can run specific image/container. – TechTalk Jan 31 '23 at 15:54

1 Answers1

0

You can use volumes to share files between the image and your host SO, even in windows. You can do it using command line (-v or --mount command line argument) or using the docker UI.

docker run -v /local/path/:/container/path ...

But i'm not really sure that you can run commands inside the volume, i guess that if binaries are compatible, it should work

Atxulo
  • 466
  • 3
  • 7
  • Thank you @Atxulo for providing the way to proceed for this issue. I am in the process of applying the suggested process by you and will update if it works fine or not. – TechTalk Feb 14 '23 at 04:28