Installing jenkins using docker image:(MAC/LINUX)
Below Steps are suggested for installing jenkins in Docker.
Prerequisites
Minimum hardware requirements:
256 MB of RAM
1 GB of drive space
Recommended hardware configuration for a small team:
4 GB+ of RAM
50 GB+ of drive space
Software requirements:
Java,Web browser,Windows operating system
Downloading and running Jenkins in Docker.
There are several Docker images of Jenkins available.
macOS and Linux:
Step1: Open up a terminal window.
Step2: Create a bridge network in Docker using the following docker network create command:
#command docker network create jenkins
Step3: In order to execute Docker commands inside Jenkins nodes, download and run the docker:dind Docker image using the following docker run command:
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
Step4:Customise official Jenkins Docker image, by executing below two steps:
a)Create Dockerfile with the following content:
FROM jenkins/jenkins:2.289.2-lts-jdk11
USER root
RUN apt-get update && apt-get install -y apt-transport-https \
ca-certificates curl gnupg2 \
software-properties-common
RUN curl -fsSL https://download.docker.com/linux/debian/gpg | apt-key add -
RUN apt-key fingerprint 0EBFCD88
RUN add-apt-repository \
"deb [arch=amd64] https://download.docker.com/linux/debian \
$(lsb_release -cs) stable"
RUN apt-get update && apt-get install -y docker-ce-cli
USER jenkins
RUN jenkins-plugin-cli --plugins "blueocean:1.24.7 docker-workflow:1.26"
b)Build a new docker image from this Dockerfile and assign the image a meaningful name, e.g. "myjenkins-blueocean:1.1":
#command docker build -t myjenkins-blueocean:1.1.
Step5:Run your own myjenkins-blueocean:1.1 image as a container in Docker using the following docker run command:
docker run \
--name jenkins-blueocean \
--rm \
--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:1.1
Step6:Proceed to the Post-installation setup wizard.
Below Steps are suggested for installing jenkins in Docker.
Prerequisites
Minimum hardware requirements:
256 MB of RAM
1 GB of drive space
Recommended hardware configuration for a small team:
4 GB+ of RAM
50 GB+ of drive space
Software requirements:
Java,Web browser,Windows operating system
Downloading and running Jenkins in Docker.
There are several Docker images of Jenkins available.
macOS and Linux:
Step1: Open up a terminal window.
Step2: Create a bridge network in Docker using the following docker network create command:
#command docker network create jenkins
Step3: In order to execute Docker commands inside Jenkins nodes, download and run the docker:dind Docker image using the following docker run command:
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
Step4:Customise official Jenkins Docker image, by executing below two steps:
a)Create Dockerfile with the following content:
FROM jenkins/jenkins:2.289.2-lts-jdk11
USER root
RUN apt-get update && apt-get install -y apt-transport-https \
ca-certificates curl gnupg2 \
software-properties-common
RUN curl -fsSL https://download.docker.com/linux/debian/gpg | apt-key add -
RUN apt-key fingerprint 0EBFCD88
RUN add-apt-repository \
"deb [arch=amd64] https://download.docker.com/linux/debian \
$(lsb_release -cs) stable"
RUN apt-get update && apt-get install -y docker-ce-cli
USER jenkins
RUN jenkins-plugin-cli --plugins "blueocean:1.24.7 docker-workflow:1.26"
b)Build a new docker image from this Dockerfile and assign the image a meaningful name, e.g. "myjenkins-blueocean:1.1":
#command docker build -t myjenkins-blueocean:1.1.
Step5:Run your own myjenkins-blueocean:1.1 image as a container in Docker using the following docker run command:
docker run \
--name jenkins-blueocean \
--rm \
--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:1.1
Step6:Proceed to the Post-installation setup wizard.