(38976) Run Jenkins in Docker Container - Jenkins Pipeline Tutorial for Beginners 1/4 - YouTube
https://www.youtube.com/watch?v=pMO26j2OUME

Transcript:
(00:00) so in this video we're gonna set up Jenkins from scratch in a docker container then we're gonna create a multi branch pipeline and connected with a git repository during this step I will also explain how to create different types of credentials in Jenkins and finally I will show you the basics of a Jenkins file to configure this multi branch pipeline so step one is to run Jenkins in a docker container so to use that we need to find an official image for Jenkins on docker hub so let's go and as you see
(00:44) here Jenkins results in an official image and some other images and if you click here you see that this image the official image has been deprecated and the last version is 2.6 T which is very old Jenkins version and instead of it we're gonna use this image here so that would be actually this one because this one is now officially maintained by the Jenkins community and also if you see the text the latest image actually has Jenkins version of to point 219 which for most of the plugins it's important to have a
(01:30) higher Jenkins version otherwise they can't be installed so we're going to take this image and this name of the image so on my command line I'm gonna execute docker run using this image right so I'm gonna dock run and the image however before I run this I need to add some options like I need to expose the port so that I can access it from my browser etc so let's actually go back and see the documentation of how to run this so all the explanation is here so these are some of the options that
(02:08) we're gonna use and actually let's go and do it so first one is I'm gonna expose the ports and the first part I'm gonna expose is port 8080 the Jenkins application inside container will run it port 8080 because Jenkins runs on Tomcat which by default starts at this port and I'm gonna bind it to my hosts port 8080 another port we can expose is 50,000 which is basically a port where drink is master and slave communicate so this will enable my Jenkins to find slaves in case I had some so the
(02:45) ports are open now another thing I'm gonna do is I'm gonna run it in detach mode and I'm also gonna bind volumes to it so to do that I'm gonna use minus B and I'm gonna use a named volume which I'm gonna call Jenkins home meaning I don't have to have this as a folder it's gonna be automatically created I'm just giving it a name which can be whatever you want and I'm gonna bind it to directory inside Jenkins container drink its image under slash bar slash Junkins hope this director is real and it's
(03:28) inside of docker container and this will create automatically create a volume now you have to be careful here because if you were to use a host volume here which basically means that you take an already existing directory on your laptop machine and binding it to the Jenkins container you might get some permission issues meaning the Jenkins user might not be able to write to that folder and that could be a problem you can actually check out my video which I made about docker volumes where you can learn in more detail how this works and the
(04:05) reason why we need to create a volume for Jenkins is to have data persistency for Jenkins so when we remove the container and restarted recreated the data will still be there and the reason why we need to persist this data is because all the Jenkins builds all the configuration and all the Jenkins plugins and also Jenkins users will be stored there so without this data you will basically have to reinitialize the whole Jenkins so important part here and we're gonna use the latest take of Jenkins and these are all the options we
(04:44) need so I'm gonna correct this one here look at here and I'm gonna run this and it's pulling the image from the docker hub it's gonna start in just couple of seconds so the image has been pulled and the docker container must be running already so if I do docker PS I see my Jenkins container running and we actually need its locks so I'm gonna do docker locks with the container ID and I'm gonna see that Jenkins started and its initial setup is needed and this is the password I'm gonna need to initialize it so I'm
(05:30) gonna copy that and if I go to localhost 8080 I will paste that password and it should start initializing so I'm going to go with the suggested plugins and this is gonna take some time to install all the plugins so depends on what technologies your application uses or what source management tools etc he will need different plugins for Jenkins and I'm just gonna go with the community one suggested ones and later of course in Jenkins you can manage these plugins you can delete them you can add new ones etc
(06:16) this is just the base so now that it's done I'm gonna create the first admin user let's go at Jenkins user some password really interesting I'm gonna just mine and I'm gonna leave it localhost Jenkins is ready and this is view I get so if I go to new item because I installed all these plugins I see different types of Jenkins projects I can create but default usually have the freestyle project freestyle project is used for simple single tasks like if you want to just run tests for example
(07:01) whereas with pipeline you can configure the whole delivery flow like test build package deploy your application etc pipeline is a more recent addition so before that they would just chain multiple freestyle projects to get a pipeline like project the pipeline project type is just for a single branch but in this video we're going to create a multi branch pipeline which will apply to multiple branches of the same repository and if I go to manage Jenkins that's where you as an admin user have all the tools to
(07:41) configure Jenkins and under manage plugins you can actually add or delete or manage or update the plugins that you have so in available I have all the plugins that I could install in addition to my Jenkins and install I have all the ones that I have actually selected at the beginning you can remove them again or you can add new plugins in the next section of this video I'm gonna show you how to create a multi branch pipeline and how to connect it to your kid repository and how to build your project using that pipeline


Q- make this video translation into step by step details tutor with details docker commends ?