To Build a pipeline for docker file

Install Docker (Skip the step you have already installed docker)

 

sudo apt install apt-transport-https ca-certificates curl software-properties-common
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o
/usr/share/keyrings/docker-archive-keyring.gpg
echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/dockerarchive-keyring.gpg] https://download.docker.com/linux/ubuntu $(lsb_release -cs)
stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
sudo apt install docker-ce
sudo systemctl status docker

Change the permission for Jenkins user (skip step if you have already done)

sudo usermod -a -G docker jenkins
sudo chown jenkins:docker /var/run/docker.sock
sudo chmod 660 /var/run/docker.sock

 

On ubuntu system create a private registry

docker run -d -p 5000:5000 --restart=always --name registry registry:2

 

From Manage plugin install docker pipeline plugin

Create a pipeline And select option “pipeline with scm”
Provide this git link

https://github.com/amitopenwriteup/cicd.git

Branch : master

Jenkinsfile name: jenkinsfile