'Docker not found error when trying to build docker image inside a docker containerized jenkins pipeline

I am trying to execute docker commands inside a docker containerized jenkins pipeline. But I get this error

+ docker -v
/var/jenkins_home/workspace/hyper-line_main@tmp/durable-278a..../script.sh: 1: /var/jenkins_home/workspace/hyper-line_main@tmp/durable-278a..../script.sh: docker: not found

Here is how I run my jenkins container

sudo docker run -d -p 10000:8080 -v /var/run/docker.sock:/var/run/docker.sock hyper-line/jenkins

Here is the Dockerfile

FROM jenkins/jenkins:lts

USER root

RUN apt-get update

RUN curl -sSL https://get.docker.com/|sh

RUN curl -fsSLO https://get.docker.com/builds/Linux/x86_64/docker-17.04.0-ce.tgz \
 && tar xzvf docker-17.04.0-ce.tgz \
 && mv docker/docker /usr/local/bin \
 && rm -r docker docker-17.04.0-ce.tgz

I have the following docker plugins in jenkins container installed

  • CloudBees Docker Build and Publish plugin
  • Docker API Plugin
  • Docker Commons Plugin
  • Docker Pipeline
  • Docker plugin
  • docker build step

Anyone please...



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source