Docker and Jenkins Learning

Source: Internet
Author: User
Tags docker ps

Docker command:

Docker Create <image-id>
Docker start <container-id>
Docker Run <image-id> = Docker Create <image-id> + docker start <container-id>
Docker PS
Docker Ps-a
Docker images
Docker Images–a
Docker Stop <container-id>
Docker Kill <container-id>
Docker Pause <container-id>
Docker RM <container-id>
Docker RMI <image-id>
Docker Commit <container-id>
Docker Build
Docker exec <running-container-id>
Docker inspect <container-id> or <image-id>
Docker Save <image-id>
Docker Export <container-id>
Docker History <image-id>

Dockerfile

From Jdk8:slim

ADD Target/udap-user.jar App.jar

entrypoint ["Java", "-djava.security.egd=file:/dev/./urandom", "-jar", "-xms128m", "-xmx128m", "/app.jar"]


Jenkinsfile

Pipeline {

Agent {label ' ICLASS5 '}

Stages {

Slave machine performs compile-and-pack uploads
Stage (' Checkout ') {

Steps {

Echo ' Start to check from GitHub '

Checkout ([$class: ' GITSCM ',
Branches: [[Name: ' */master ']],
Dogeneratesubmoduleconfigurations:false,
Extensions: [
[$class: ' Sparsecheckoutpaths ',
sparsecheckoutpaths:[[$class: ' Sparsecheckoutpath ', Path: ' Udap-user ']]
], submodulecfg: [],
Userremoteconfigs: [[credentialsid: ' github-wwlleo0730 ', url: ' Https://github.com/udap/mediabox ']]
}
}

Stage (' MVN Build & Test ') {

Steps {

Echo ' Start to mvn build '

SH "Docker run-i--rm-v ${env. Workspace}/udap-user:/usr/src/workspace-v/root/.m2/repository/:/root/.m2/repository-v/opt/maven/settings.xml:/ Root/.m2/settings.xml-w/usr/src/workspace maven mvn clean package-u-dmaven.test.skip=true "
}
}

Stage (' Remove old container ') {

steps{

Sh ' cid=$ (docker PS | grep iclass.cn/$JOB _name | awk \ ' {print $1}\ ')
If ["$CID"! = ""];then
Docker Rm-f $CID
Fi ""
}

}

Stage (' rebuild image ') {

Steps {

Sh ' cid=$ (Docker images | grep iclass.cn/$JOB _name | awk \ ' {print $1}\ ')

If ["$CID"! = ""];then
Docker RMI iclass.cn/$JOB _name
Fi ""

Script {
Docker.build (' iclass.cn/$JOB _name ', './udap-user ')
}
}
}

Stage (' Restart container ') {

steps{

Echo ' Start ... '
Sh ' docker run-d--name $JOB _name-p 4010:4010-e "spring_profiles_active=test"-E "eureka_instance_ip-address=10.80.228 .221 "iclass.cn/$JOB _name '
}

}
}
}

Docker and Jenkins Learning

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.