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