docker pull jenkins/jenkins
docker build -t myjenkins-blueocean:2.414.2-1 .
You might face some error during the build like (unable to locate package docker-ce-cli) so before proceeding make sure you run the following commands :-
sudo apt-get update
sudo apt install apt-transport-https ca-certificates curl software-properties-common
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add
- (This might work as it is deprecated)sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu kinetic stable"
docker network create jenkins
docker run
--name jenkins-docker
--rm
--detach
--privileged
--network jenkins
--network-alias docker
--env DOCKER_TLS_CERTDIR=/certs
--volume jenkins-docker-certs:/certs/client
--volume jenkins-data:/var/jenkins_home
--publish 2376:2376
docker:dind
--storage-driver overlay2
docker run
--name jenkins-blueocean
--restart=on-failure
--detach
--network jenkins
--env DOCKER_HOST=tcp://docker:2376
--env DOCKER_CERT_PATH=/certs/client
--env DOCKER_TLS_VERIFY=1
--publish 8080:8080
--publish 50000:50000
--volume jenkins-data:/var/jenkins_home
--volume jenkins-docker-certs:/certs/client:ro
myjenkins-blueocean:2.414.2-1
docker exec jenkins-blueocean cat /var/jenkins_home/secrets/initialAdminPassword
docker exec -it jenkins-blueocean bash
-> Non-Root Access
docker exec -it -u 0 {CONTAINER ID} /bin/bash
-> Root Access
Python Package does not comes with base image of Jenkins so we required to access the Jenkin shell with Root Access to download the Python Package.
docker exec -it -u 0 {CONTAINER ID} /bin/bash
to open an interactive terminal within the Docker Container as root (user 0).
apt-get update
and apt-get install python3
and apt-get install python3-pip
to install Python3 and pip within the Docker container.
docker run -d --restart=always -p 127.0.0.1:2376:2375 --network jenkins -v /var/run/docker.sock:/var/run/docker.sock alpine/socat tcp-listen:2375,fork,reuseaddr unix-connect:/var/run/docker.sock
docker inspect <contrainer_id>
The above container will be used as a external Docker container for jenkins
docker pull masprtech1/jenkins-agent-python
Build Image :- Docker File link