DevOps Stack Exchange is a question and answer site for software engineers working on automated testing, continuous delivery, service integration and monitoring, and building SDLC infrastructure. Join them; it only takes a minute:

whenever I start building a pipeline project, it gives me ,,Docker is not found'' error

whenever I try to work around this by installing npm plugin and running bash script npm install as a build step, I get node/npm not found

Solutions I've found and tried:

According to official Jenkins docker image docs, all one is supposed to do is to mount docker.socket in dockerfile/docker-compose file and it should ,,just'' work (it doesn't) - example:

volumes:
- /var/run/docker.sock:/var/run/docker.sock

The only solution that was close to working as intended, was to install docker directly on Jenkins container and then setting user for jenkins. It works, but only until docker image is running. When I kill it and run it again, docker isn't installed on container and so every pipeline fails again. I can't have that, I cannot have a downtime caused by say remote server being down. I'd have to manually install docker on that Jenkins container every time something was down.

1 Answer
1

The build node executes the build. In that case, all tools the build needs have to be installed on that node/slave.

The build is run inside a Docker container (with a build node as host). In that case, the Docker image for the build needs to contain all the tools the build needs, but the Jenkins node doesn't have to.

"Kill and run again" as in docker stop $name; docker rm $name; docker run ...? Sure, that deletes all data local to that container.

If you want to stop and restart the same container, use docker stop and docker start instead.

If you want to carry data over from one container to another, use volumes.

If you want to go with 1.1 and you need all your Jenkins nodes to come equipped with a certain set of tools (such as Docker, npm, ...), create your own Docker image for them.