Jenkins Building Docker containers

Source: Internet
Author: User
Tags docker ps

First, the process

Svn-->jenkins-->build Image-->run Container


Second, step

1. Install Jenkins

Download the Jenkins installation package (Jenkins.war) and deploy to Tomcat.

2. Initial Configuration

Initialize the configuration follow the recommendations to install the necessary plug-ins, maven students need to install Maven Integration plugin, not required here.

3, building docker configuration

1) Click "New"--> Enter item Name--> " build a free-style project --"OK"

650) this.width=650; "Src=" https://s3.51cto.com/wyfs02/M00/8C/C4/wKioL1h3ahCzDmf8AACPNAcKNs8684.png-wh_500x0-wm_ 3-wmp_4-s_3506191768.png "title=" 1.png "alt=" Wkiol1h3ahczdmf8aacpnackns8684.png-wh_50 "/>


2) Configure SVN, the account can be entered in advance in credentials, then select here;

650) this.width=650; "Src=" https://s5.51cto.com/wyfs02/M02/8C/C4/wKioL1h3atGzZO84AAC7RZqLg4Q356.jpg-wh_500x0-wm_ 3-wmp_4-s_4235445041.jpg "title=" 2.jpg "alt=" Wkiol1h3atgzzo84aac7rzqlg4q356.jpg-wh_50 "/>


3) Build trigger Condition: Trigger the build when the code is updated;

650) this.width=650; "Src=" https://s1.51cto.com/wyfs02/M02/8C/C4/wKioL1h3ccbw7ebBAAB3iCXnckc993.jpg-wh_500x0-wm_ 3-wmp_4-s_49228616.jpg "title=" 3.jpg "alt=" Wkiol1h3ccbw7ebbaab3icxnckc993.jpg-wh_50 "/>


4) Build Script

650) this.width=650; "Src=" https://s4.51cto.com/wyfs02/M02/8C/C4/wKioL1h3chCAVEZbAAC1NaJjZvs921.jpg-wh_500x0-wm_ 3-wmp_4-s_3637663786.jpg "title=" 4.jpg "alt=" Wkiol1h3chcavezbaac1najjzvs921.jpg-wh_50 "/>

#!/bin/shidset +eecho  ' >>> Get old  Container id ' cid=$ (docker ps | grep  "sshd"  | awk  ' {print $1} ') echo  $CIDcd  /root/docker/sshddocker build -t sshd . echo  ' >>>  stopping adn remove old container ' if [  ' $CID  !=  ""  ];then   docker stop  $CID   docker rm  $CIDfiecho   ' >>>  Starting new container ' docker run -p 3000:80 -d --name sshd sshd 

The script does not judge the container that is not started but already exists, and the students who need it can add their own

Docker RM ' Docker ps-a|grep sshd|awk ' $NF = = "sshd" {print} '

5, click to save, this configuration is complete. After the code is submitted to SVN, it triggers an automatic build

650) this.width=650; "Src=" https://s4.51cto.com/wyfs02/M02/8C/C4/wKioL1h3cwGQYowsAAAi6VkpA1U809.jpg-wh_500x0-wm_ 3-wmp_4-s_3364428489.jpg "title=" 5.jpg "alt=" Wkiol1h3cwgqyowsaaai6vkpa1u809.jpg-wh_50 "/>

650) this.width=650; "Src=" https://s3.51cto.com/wyfs02/M01/8C/C5/wKioL1h3dpPBZvLSAADu-9xqTzI206.jpg-wh_500x0-wm_ 3-wmp_4-s_87355130.jpg "title=" 6.jpg "alt=" Wkiol1h3dppbzvlsaadu-9xqtzi206.jpg-wh_50 "/>

This article is from the "drag tail in the painting" blog, please be sure to keep this source http://cangzihu.blog.51cto.com/6671848/1891598

Jenkins Building Docker containers

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.