<mirrors> <!-- mirror | Specifies a repository mirror site to use instead of a given repository. The repository that | this mirror serves has an ID that matches the mirrorOf element of this mirror. IDs are used | for inheritance and direct lookup purposes, and must be unique across the set of mirrors. | <mirror> <id>mirrorId</id> <mirrorOf>repositoryId</mirrorOf> <name>Human Readable Name for this Mirror.</name> <url>http://my.repository.com/repo/path</url> </mirror> --> <mirror> <id>alimaven</id> <mirrorOf>central</mirrorOf> <name>aliyun maven</name> <url>http://maven.aliyun.com/nexus/content/repositories/central/</url> </mirror> </mirrors>
# 先删除之前的容器和镜像文件 if [ "$(docker ps -a | grep listen-app)" ]; then docker stop listen-app docker rm listen-app fi if [ "$(docker images -q listen-app)" ]; then docker rmi listen-app fi # demo1为当前任务名称 cd /var/jenkins_home/workspace/demo1 docker build -t changwang/listen-app . docker run -itd -p 8081:8081 --name listen-app changwang/listen-app
到这步,配置基本完成,后面的按需进行修改,也可以不动
启动任务
控制台输出
进入首页,执行任务,查看控制台输出,当出现如下类似内容时,构建完成
docker
查看镜像,后端项目正常启动
1 2 3 4 5
root@106eb080017c:/# docker images REPOSITORY TAG IMAGE ID CREATED SIZE changwang/listen-app latest ee3eeef9b8af About a minute ago 312MB jenkins/jenkins lts 0bd9f204ffc3 2 weeks ago 470MB openjdk 11-jre-slim 764a04af3eff 22 months ago 223MB