question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Is it possible to actual run the docker steps?

See original GitHub issue
Building docker image for runtime null
[Pipeline] sh
[job] Running shell script
+ docker build -t tests:null -f Dockerfile.tests .
/tmp/jenkinsTests.tmp/jenkins8996889882339540707test/workspace/job@tmp/durable-57fedee8/script.sh: 2: /tmp/jenkinsTests.tmp/jenkins8996889882339540707test/workspace/job@tmp/durable-57fedee8/script.sh: docker: not found
[Pipeline] }
[Pipeline] // stage
[Pipeline] stage
[Pipeline] { (Tests Execution)
...
...
...
ERROR: script returned exit code 127
Finished: FAILURE

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:1
  • Comments:7 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
marcellodesalescommented, Apr 23, 2018

@ndeloof @schnatterer I actually got it to work following the suggestions from https://forums.docker.com/t/using-docker-in-a-dockerized-jenkins-container/322. I could get it to work to just run a container with the following volumes:

  • Mount the /var/run/docker.sock
  • Mount the docker command

Solution

  • I built the image locally and tagged as marcellodesales/jenkinsfile-runner
  • Running a container and mounting the volumes described

This is actually an acceptable solution for my case using Docker for Mac to support development of the Pipeline.

$ docker run -v $(pwd):/workspace  \
      -v /var/run/docker.sock:/var/run/docker.sock \
      -v $(which docker):$(which docker) marcellodesales/jenkinsfile-runner
Started
Running in Durability level: PERFORMANCE_OPTIMIZED
[
...
...
[Pipeline] [Validate Test] }
[Pipeline] // parallel
[Pipeline] }
[Pipeline] // stage
[Pipeline] stage
[Pipeline] { (Build Test Image)
[Pipeline] script
[Pipeline] {
[Pipeline] }
[Pipeline] // script
[Pipeline] echo
Building docker image for tests from build stage null
[Pipeline] sh
[job] Running shell script
+ docker build -t tests:null -f Dockerfile --target builder .
Sending build context to Docker daemon  13.75MB
Step 1/9 : FROM maven:3.2.5-jdk-8 as builder
 ---> 95dd59c15f5d
Step 2/9 : MAINTAINER marcello.desales@gmail.com
 ---> Using cache
 ---> e4edaeb48381
Step 3/9 : ADD ./pom.xml /opt/build/pom.xml
 ---> Using cache
 ---> 2ca95e0b276e
Step 4/9 : ADD ./settings.xml /opt/build/settings.xml
 ---> Using cache
 ---> 1c52ecafca2b
Step 5/9 : WORKDIR  /opt/build/
 ---> Using cache
 ---> e2f5d1a6467f
Step 6/9 : RUN mvn -s settings.xml -B -e -C -T 1C org.apache.maven.plugins:maven-dependency-plugin:3.0.2:go-offline
 ---> Using cache
 ---> 9212f3bd2e5b
Step 7/9 : ADD ./src /opt/build/src
 ---> f7e2cc9f9aa6
Step 8/9 : RUN mvn -s settings.xml install -P embedded -Dmaven.test.skip=true -B -e -o -T 1C verify
 ---> Running in 52b96eb70b06
[INFO] Error stacktraces are turned on.
[INFO] Scanning for projects...
[INFO]
[INFO] Using the MultiThreadedBuilder implementation with a thread count of 4
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building spring-cloud-config-server 1.1.6-SNAPSHOT
[INFO] ---------------------------------------------------
...
...
...
[INFO] --- maven-failsafe-plugin:2.20.1:integration-test (integration-test) @ spring-cloud-config-server ---
[INFO] Tests are skipped.
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 27.438 s (Wall Clock)
[INFO] Finished at: 2018-04-23T21:02:49+00:00
[INFO] Final Memory: 46M/216M
[INFO] ------------------------------------------------------------------------
Removing intermediate container 52b96eb70b06
 ---> bbefce46d3bd
Step 9/9 : CMD mvn -s settings.xml -Dtest="!*IT,!*IntegrationTest" -P jacoco test
 ---> Running in aa7ab08da632
Removing intermediate container aa7ab08da632
 ---> a65a5a81ee21
Successfully built a65a5a81ee21
Successfully tagged tests:null
[Pipeline] }
[Pipeline] // stage
[Pipeline] stage
[Pipeline] { (Tests Execution)
[Pipeline] parallel
[Pipeline] [Execute Unit Tests] { (Branch: Execute Unit Tests)
[Pipeline] [Execute Integration Tests] { (Branch: Execute Integration Tests)
[Pipeline] [Execute Unit Tests] stage
0reactions
ndeloofcommented, Apr 23, 2018

I can’t see any reason the jenkinsfile-runner could not run docker steps, it just need docker command line available in the current node, i.e local machine running jenkinsfile-runner.

Based on your comment :

Could we somehow mount the docker socket and mount or install the client binary into jenkinsfile-runner?

it sounds like you use jenkinsfile-runner from a docker image, not running directly as a CLI tool. Doing so you indeed need to customize the docker image to have docker CLI installed and grant access to docker infrastructure.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Containerize an application - Docker Documentation
Start your container using the docker run command and specify the name of the image you just created: $ docker run -dp 3000:3000...
Read more >
docker run - Docker Documentation
docker run: The `docker run ` command first `creates` a writeable container layer over the specified image, and then `starts` it using the...
Read more >
Docker run reference
Docker runs processes in isolated containers. A container is a process which runs on a host. The host may be local or remote....
Read more >
Run your tests - Docker Documentation
Run your tests · Prerequisites . Work through the steps to build an image and run it as a containerized application in...
Read more >
Docker Engine post-installation steps
Manage Docker as a non-root user · Create the docker group. sudo groupadd docker · Add your user to the docker...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found