{"id":475,"date":"2016-03-10T11:17:46","date_gmt":"2016-03-10T11:17:46","guid":{"rendered":"http:\/\/www.scmgalaxy.com\/tutorials\/2016\/03\/10\/install-jenkins-using-docker\/"},"modified":"2018-09-19T11:46:05","modified_gmt":"2018-09-19T11:46:05","slug":"install-jenkins-using-docker","status":"publish","type":"post","link":"https:\/\/www.devopsschool.com\/blog\/install-jenkins-using-docker\/","title":{"rendered":"How to Install Jenkins using Docker | Step by step guide | scmGalaxy"},"content":{"rendered":"<div><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-3058 aligncenter\" src=\"http:\/\/www.scmgalaxy.com\/tutorials\/wp-content\/uploads\/2016\/03\/install-jenkins-using-docke.png\" alt=\"\" width=\"600\" height=\"400\" srcset=\"https:\/\/www.devopsschool.com\/blog\/wp-content\/uploads\/2016\/03\/install-jenkins-using-docke.png 600w, https:\/\/www.devopsschool.com\/blog\/wp-content\/uploads\/2016\/03\/install-jenkins-using-docke-300x200.png 300w\" sizes=\"auto, (max-width: 600px) 100vw, 600px\" \/><\/div>\n<div><strong>Step 1: Installing Docker<\/strong><\/div>\n<div>\n<p>[code]<br \/>\n$ apt-get install docker (Ubuntu)<br \/>\n$ yum install docker \u00a0(RHEL\/CENTOS)<br \/>\n[\/code]<\/p>\n<\/div>\n<div>For more info, please following this <a href=\"http:\/\/www.scmgalaxy.com\/scm\/software-containers\/how-to-install-docker-in-linux.html\" target=\"_blank\" rel=\"noopener\">http:\/\/www.scmgalaxy.com\/scm\/software-containers\/how-to-install-docker-in-linux.html<\/a><\/div>\n<div><\/div>\n<div><strong>Step 2: \u00a0First, pull the official jenkins image from Docker repository.<\/strong><\/div>\n<div>\n<p>[code]$ docker pull jenkins\u00a0[\/code]<\/p>\n<\/div>\n<div><\/div>\n<div>\n<p><strong>Step 3: Next, run a container using this image and map data directory from the container to the host; e.g in the example below \/var\/jenkins_home from the container is mapped to jenkins\/ directory from the current path on the host. Jenkins 8080 port is also exposed to the host as 49001.<\/strong><\/p>\n<p><strong>Mapping port 8080 on the host to the container (the web ui), port 50000 to port 50000 (for build agents). Run with `-p 50000:50000` so you can connect JNLP slaves. For port 50000. This is to handle connections from JNLP based build slaves.\u00a0This will store the workspace in \/var\/jenkins_home. All Jenkins data lives in there\u00a0including plugins and configuration.<\/strong><\/p>\n<\/div>\n<div>\n<div>\n<p>[code]$ docker run -d -p 8080:8080 -p 50000:50000 jenkins\u00a0[\/code]<\/p>\n<\/div>\n<div><\/div>\n<div><strong>This will store the jenkins data in \/your\/home on the host. Ensure that \/your\/home is accessible by the jenkins user in container (jenkins user &#8211; uid 1000) or use -u\u00a0some_other_user parameter with docker run.<\/strong><\/div>\n<div>\n<p>[code]$ docker run -d -p 8080:8080 -p 50000:50000 -u root -v $PWD\/jenkins:\/var\/jenkins_home jenkins\u00a0[\/code]<\/p>\n<\/div>\n<div><\/div>\n<div>\u00a0<strong>Other Example:<\/strong><\/div>\n<div>\n<p>[code]docker run -d -p 49001:8080 -v $PWD\/jenkins:\/var\/jenkins_home -t jenkins -u root\u00a0[\/code]<\/p>\n<\/div>\n<div><\/div>\n<div><strong>This will store the jenkins data in \/your\/home on the host. Ensure that \/your\/home is accessible by the jenkins user in container (jenkins user &#8211; uid 1000) or use -u some_other_user parameter with docker run.\u00a0<\/strong><strong>This information is also found in the Dockerfile. So all you need to do is to ensure that the directory $PWD\/jenkins is own by UID 1000:<\/strong><\/div>\n<div>\n<p>[code]<br \/>\n$ mkdir jenkins<br \/>\n$ chown 1000 jenkins<br \/>\n$ docker run -d -p 49001:8080 -v $PWD\/jenkins:\/var\/jenkins_home -t jenkins<br \/>\n[\/code]<\/p>\n<div><strong>How to see the Jenkins log?<\/strong><\/div>\n<div>\n<p>[code]$ docker exec name tail -f \/var\/log\/jenkins\/jenkins.log<br \/>\nWhere name = &#8211;name\u00a0[\/code]<\/p>\n<\/div>\n<\/div>\n<div><strong>Step 3: \u00a0Access to j=Jenkins<\/strong><\/div>\n<div>As we have successfully run Jenkins Container, we can browse Jenkins Web Interface using our Web Browser by pointint to http:\/\/ip-address:49001 or http:\/\/localhost:49001 according to the configuration.<\/div>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>Step 1: Installing Docker [code] $ apt-get install docker (Ubuntu) $ yum install docker \u00a0(RHEL\/CENTOS) [\/code] For more info, please following this http:\/\/www.scmgalaxy.com\/scm\/software-containers\/how-to-install-docker-in-linux.html Step 2: \u00a0First, pull the official jenkins image from Docker repository. [code]$ docker pull jenkins\u00a0[\/code] Step 3: Next, run a container using this image and map data directory from the container to&#8230;<\/p>\n","protected":false},"author":1,"featured_media":3058,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_kad_post_transparent":"","_kad_post_title":"","_kad_post_layout":"","_kad_post_sidebar_id":"","_kad_post_content_style":"","_kad_post_vertical_padding":"","_kad_post_feature":"","_kad_post_feature_position":"","_kad_post_header":false,"_kad_post_footer":false,"_kad_post_classname":"","_joinchat":[],"footnotes":""},"categories":[42,4862],"tags":[567,1122,545,1216,237,1215,145,1214,1217,1218,1219,593,732,213],"class_list":["post-475","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-jenkins","category-docker","tag-docker","tag-guide","tag-how","tag-how-to-install-jenkins-using-docker","tag-install","tag-install-jenkins-using-docker","tag-jenkins","tag-jenkins-installation-guide","tag-jenkins-installation-process","tag-jenkins-installation-tutorial","tag-jenkins-installation-using-docker","tag-process","tag-steps","tag-tutorial"],"_links":{"self":[{"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/posts\/475","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/comments?post=475"}],"version-history":[{"count":7,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/posts\/475\/revisions"}],"predecessor-version":[{"id":4930,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/posts\/475\/revisions\/4930"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/media\/3058"}],"wp:attachment":[{"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/media?parent=475"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/categories?post=475"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/tags?post=475"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}