First, in your base image install Docker
FROM ubuntu:latest
...
RUN apt-get update \
&& apt-get install -y docker.io \
...
When running the pipeline tell Jenkins to mount Docker socket inside Docker container by adding below command
pipeline {
agent {
docker {
image '<previously built docker image>'
args '-v /var/run/docker.sock:/var/run/docker.sock' # <--- This line
}
}
...