I am learning Jenkins. I have created Jenkins container with docker and trying to run jenkins from there.
services:
jenkins:
image: jenkins/jenkins:lts
container_name: jenkins
restart: always
ports:
- "8080:8080"
- "50000:50000"
volumes:
- jenkins_home:/var/jenkins_home
networks:
- jenkins
networks:
jenkins:
volumes:
jenkins_home:
I have also installed docker-pipline plugin to my Jenkins Container. I checked the restart api button after the plugin is installed.
My script for pipeline job is:
pipeline {
agent any
stages {
stage('w/o docker') {
steps {
sh 'echo "Without docker"'
}
}
stage('w docker') {
agent{
docker{
image 'node:18-alpine'
}
}
steps {
sh 'echo "With docker"'
}
}
}
}
But when I build it I am getting the following error:
Started by user Fahad Md kamal
[Pipeline] Start of Pipeline
[Pipeline] node
Running on Jenkins in /var/jenkins_home/workspace/Docker build Pipeline
[Pipeline] {
[Pipeline] stage
[Pipeline] { (w/o docker)
[Pipeline] sh
+ echo Without docker
Without docker
[Pipeline] }
[Pipeline] // stage
[Pipeline] stage
[Pipeline] { (w docker)
[Pipeline] node
Running on Jenkins in /var/jenkins_home/workspace/Docker build Pipeline@2
[Pipeline] {
[Pipeline] isUnix
[Pipeline] withEnv
[Pipeline] {
[Pipeline] sh
+ docker inspect -f . node:18-alpine
/var/jenkins_home/workspace/Docker build Pipeline@2@tmp/durable-5dab51a9/script.sh.copy: 1: docker: not found
[Pipeline] isUnix
[Pipeline] withEnv
[Pipeline] {
[Pipeline] sh
+ docker pull node:18-alpine
/var/jenkins_home/workspace/Docker build Pipeline@2@tmp/durable-74f03549/script.sh.copy: 1: docker: not found
[Pipeline] }
[Pipeline] // withEnv
[Pipeline] }
[Pipeline] // withEnv
[Pipeline] }
[Pipeline] // node
[Pipeline] }
[Pipeline] // stage
[Pipeline] }
[Pipeline] // node
[Pipeline] End of Pipeline
ERROR: script returned exit code 127
Finished: FAILURE
I have no idea what I am doing wrong here, and also kind of getting frustrated with it since I am facing the problem for over weeks now. I would be glad if you could help me.