devops-docker-cx-server icon indicating copy to clipboard operation
devops-docker-cx-server copied to clipboard

dockerExecute in custom stage

Open marcorosa opened this issue 4 years ago • 1 comments

I have a running docker cx-server instance locally (macOS Big Sur 11.2.3, docker version 20.10.5)

I set up a pipeline with a custom stage, where I would like to execute some operations in a docker container (I leave a simple apt-get update for testing)

    stage('custom-stage') {
        dockerExecute(script: this, dockerImage: 'python:3.7'){
            sh "apt-get update"
        }
    }

Yet, this stage fails with the following log

--- Begin library step of: dockerExecute ---
+ docker ps -q
Got permission denied while trying to connect to the Docker daemon socket at unix:///var/run/docker.sock: Get http://%2Fvar%2Frun%2Fdocker.sock/v1.24/containers/json: dial unix /var/run/docker.sock: connect: permission denied

[WARNING][dockerExecute] Cannot connect to docker daemon (command 'docker ps' did not return with '0'). Configured docker image 'python:3.7' will not be used.

[INFO][dockerExecute] Running on local environment.

+ apt-get update
Reading package lists...
E: List directory /var/lib/apt/lists/partial is missing. - Acquire (13: Permission denied)

---------------------------------------------------------- 
--- An error occurred in the library step: dockerExecute 
---------------------------------------------------------- 
The following parameters were available to the step: 
*** 
*** to show step parameters, set verbose:true in general pipeline configuration 
*** WARNING: this may reveal sensitive information. *** 
*** 

The error was: 
*** 
hudson.AbortException: script returned exit code 100 
*** 

Further information: 
* Documentation of library step dockerExecute: https://sap.github.io/jenkins-library/steps/dockerExecute/ 
* Source code of library step dockerExecute: https://github.com/SAP/jenkins-library/blob/master/vars/dockerExecute.groovy 
* Library documentation: https://sap.github.io/jenkins-library/ 
* Library repository: https://github.com/SAP/jenkins-library/ 
 
---------------------------------------------------------- 
--- End library step of: dockerExecute --- 

are docker container stages supported by cx-server? Am I missing something?

marcorosa avatar Mar 26 '21 10:03 marcorosa

Hi @marcorosa

thanks for reporting.

Got permission denied while trying to connect to the Docker daemon socket at unix:///var/run/docker.sock: Get http://%2Fvar%2Frun%2Fdocker.sock/v1.24/containers/json: dial unix /var/run/docker.sock: connect: permission denied

[WARNING][dockerExecute] Cannot connect to docker daemon (command 'docker ps' did not return with '0'). Configured docker image 'python:3.7' will not be used.

dockerExecute tries to run the command locally if it is not able to run it in docker.

Might be a duplicate of https://github.com/SAP/devops-docker-cx-server/issues/99

I don't have much time to look into this currently, please try running cx-server in a linux vm meanwhile.

Best,

Florian

fwilhe avatar Mar 29 '21 12:03 fwilhe