I had setup Jenkins using the Jenkins Docker Image on an AWS ECS Cluster with just one EC2 instance.
After the initial setup, I tried running the hello-world pipeline from Jenkins documentation. I see that I am getting "docker: not found"
I understand that this is because Docker is not installed and available within the Jenkins Docker container. However, I have a fundamental question on whether I should proceed with installing Docker inside the running Jenkins Docker container (to use that as the base image) or not. When I researched around, I found this blog post and this SO Answer.
I wanted to follow these suggestions and I tried mounting the volume /usr/bin/docker
and the socket /var/run/docker.sock
from the host EC2 / ECS instance to the Jenkins Container. After this, when I ran the docker version
command to test the setup, I am getting linux library issues - docker: error while loading shared libraries: libltdl.so.7: cannot open shared object file: No such file or directory
which indicates that the setup did not go well.
Here are my questions -
- How to run Jenkins pipelines that use Docker containers when running Jenkins based on a Docker container? I want to be able to pull / build / run docker containers, say for example - run the hello-world pipeline example referenced above?
My end goal is to create 2 types of Jenkins jobs that do the following -
Jenkins Job Type 1
- Check out repository from BitBucket cloud
- Run a shell script to build a docker image for a java project (possibly using the maven jib plugin)
- Publish to AWS ECR. (assuming this can be done using the cloudbees plugin)
Jenkins Job Type 2
- Pull the image published from Job Type 1 from AWS ECR
- Create a container from the image (which essentially runs the java application)
- The container itself could be run on the same Jenkins ECR cluster with slaves. But, again should the slaves have docker installed within them to pull and run the image from ECR?
Asking these questions after a good amount of research and not finding answers. Any guidance is appreciated. Thanks.