Ubuntu+docker+jenkins安装详细指南
最近项目上开始实行自动化测试,避免不了与jenkins等持续集成工具打交道,今天就给大家分享一下有关jenkins的简单安装和使用
1,准备环境
(1)ubuntu系统
(2)docker
(3)jenkins
2,安装docker
(1)安装 sudo apt-get install -y docker.io
(2)启动docker systemctl start docker 可以设置永久开机自启动 systemctl enable docker
(3)docker version 或 docker -v 可以查看版本,说明docker安装成功了
(4)安装完成后,当你执行docker run hello-world,你可以发现docker先从本地找hello-world镜像,没有的话,就从官方仓库找
docker run hello-world
Unable to find image 'hello-world:latest' locally
latest: Pulling from library/hello-world
(5)在仓库中搜索镜像,比如搜索ubuntu镜像,docker search ubuntu 找到之后(并不一定有,所以可能需要换仓库),进行拉取镜像docker pull ubuntu
有的镜像很大,仓库又在国外,速度很慢。我们可以自己搭建私服,也可以用一些其他地址。
目前世界上最大最知名的公共仓库是Docker官方的Docker Hub,国内比较知名的有:Docker Pool、阿里云仓库等
(6)阿里云仓库镜像服务配置,首先在阿里云https://www.aliyun.com/上注册账户,登录之后,进入控制台-选择docker容器镜像服务-进入镜像加速器-按照上面说的方法在ubuntu上配置即可;
配置完成执行docker info | grep http就可以看到刚才配置的仓库地址了
关于docker的具体使用方法,不在此赘述,可以参考
菜鸟教程https://www.runoob.com/docker/docker-tutorial.html
官方英文文档https://docs.docker.com/
中文文档http://www.dockerinfo.net/document
3,安装jenkins
相关参考
https://jenkins.io/zh/doc/book/installing/
https://hub.docker.com/r/jenkins/jenkins
(1)准备本地文件,用来保存重要内容,以防容器被意外破坏和删除
mkdir /usr/local/workspace/jenkins;chmod 777 jenkins
(2)执行docker pull和docker run命令,启动容器,这个命令如果本地没有镜像,会自动的从仓库拉取
docker pull jenkins/jenkins:lts
lts: Pulling from jenkins/jenkins
9cc2ad81d40d: Pull complete
e6cb98e32a52: Pull complete
ae1b8d879bad: Pull complete
42cfa3699b05: Pull complete
8d27062ef0ea: Pull complete
9b91647396e3: Pull complete
7498c1055ea3: Pull complete
7649b1010bf2: Pull complete
1c3f5e14c681: Pull complete
a204aa63f757: Pull complete
9b57f731dd16: Pull complete
d21f82c5429a: Pull complete
440e5fb06ea6: Pull complete
5d43ca048df2: Pull complete
1421ef7f2b0c: Pull complete
0c2b6150f92f: Pull complete
9e0d2e7a610a: Pull complete
36bd756f5339: Pull complete
e27e28c0b503: Pull complete
Digest: sha256:7cfe34701992434cc08bfd40e80e04ab406522214cf9bbefa57a5432a123b340
Status: Downloaded newer image for jenkins/jenkins:lts
启动一个名为jenkins的容器,并且将容器的8080和50000端口直接映射到本机的8080和50000端口,文件对应本地的/usr/local/workspace/jenkins
docker run -p 8080:8080 -p 50000:50000 -v /usr/local/workspace/jenkins:/var/jenkins_home --name jenkins -idt jenkins/jenkins:lts
Unable to find image 'jenkins:latest' locally
latest: Pulling from library/jenkins
55cbf04beb70: Pull complete
1607093a898c: Pull complete
9a8ea045c926: Pull complete
d4eee24d4dac: Pull complete
c58988e753d7: Pull complete
794a04897db9: Pull complete
70fcfa476f73: Pull complete
0539c80a02be: Pull complete
54fefc6dcf80: Pull complete
911bc90e47a8: Pull complete
38430d93efed: Pull complete
7e46ccda148a: Pull complete
c0cbcb5ac747: Pull complete
35ade7a86a8e: Pull complete
aa433a6a56b1: Pull complete
841c1dd38d62: Pull complete
b865dcb08714: Pull complete
5a3779030005: Pull complete
12b47c68955c: Pull complete
1322ea3e7bfd: Pull complete
Digest: sha256:eeb4850eb65f2d92500e421b430ed1ec58a7ac909e91f518926e02473904f668
Status: Downloaded newer image for jenkins:latest
7c0c83b83707e40c879156449ea783a24a984fab9a3105e62b298d3a00ffdfaa
(3)验证是否安装成功
执行命令docker logs -f jenkins查看容器的控制台日志,看到如下信息表示jenkins服务启动成功
Aug 29, 2019 5:49:10 AM hudson.model.UpdateSite updateData
INFO: Obtained the latest update center data file for UpdateSource default
Aug 29, 2019 5:49:10 AM hudson.WebAppMain$3 run
INFO: Jenkins is fully up and running
Aug 29, 2019 5:49:39 AM hudson.model.DownloadService$Downloadable load
INFO: Obtained the updated data file for hudson.tasks.Maven.MavenInstaller
Aug 29, 2019 5:49:41 AM hudson.model.DownloadService$Downloadable load
INFO: Obtained the updated data file for hudson.tools.JDKInstaller
Aug 29, 2019 5:49:41 AM hudson.model.AsyncPeriodicWork$1 run
INFO: Finished Download metadata. 45,776 ms
或者docker ps -a | grep jenkins 看到up,表示运行状态
docker ps -a | grep jenkins
95e49fb019ce jenkins "/bin/tini -- /usr/l…" 6 seconds ago Up 4 seconds 0.0.0.0:8080->8080/tcp, 0.0.0.0:50000->50000/tcp jenkins
如果想要开机自动重启容器,可以设置 docker update --restart=always jenkins
4,使用jenkins
(1)访问jenkins
http://192.168.1.119:8080,按照界面提示配置密码登录
页面提示密码文件的位置:/var/jenkins_home/secrets/initialAdminPassword,由于我们已经将/var/jenkins_home目录映射到本机的/usr/local/workspace/jenkins目录,所以密码文件在这个目录
(2)安装推荐插件,根据界面提示进行即可,耐心等待吧
问题:我遇到了,在安装完插件,如果重新刷新进入jenkins的时候,输入完第一步的密码之后,页面一直处于空白加载中,无法继续访问,搜查了网上资料解决了
在$JENKINS_HOME/hudson.model.UpdateCenter.xml文件中,也就是/usr/local/workspace/jenkins/hudson.model.UpdateCenter.xml默认内容如下
<?xml version='1.1' encoding='UTF-8'?>
<sites>
<site>
<id>default</id>
<url>https://updates.jenkins-ci.org/update-center.json</url>
</site>
</sites>
把url改成http://mirror.xmission.com/jenkins/updates/update-center.json
或者直接访问http://192.168.1.119:8080/pluginManager/advanced
然后在下面更改一下
(3)创建一个管理员账户,根据界面提示进行即可
问题:登录之后,可能显示空白页
访问http://192.168.1.119:8080/restart 登录管理员账户就可以了
Ubuntu+docker+jenkins安装详细指南的更多相关文章
- Centos + docker,Ubuntu + docker介绍安装及详细使用
docker笔记 常用命令 设置docker开机自启:sudo chkconfig docker on 查所有镜像: docker images 删除某个镜像:docker rmi CONTAINER ...
- VMware Tools (ubuntu系统)安装详细过程与使用
前一段时间博主在VMware虚拟机上安装了Ubuntu系统,如果还没有安装的同学可以参考博主上一篇文章:VMware Ubuntu安装详细过程. 猿友们都知道linux不太好用,如果你想将你主机Win ...
- ubuntu docker inflxudb(安装 使用 备份 还原 以及python编码) telegraf Grafana
inflxudb1.7.7 1.拉取最新的镜像 docker pull influxdb 2.运行实例: docker run -d --restart=always -p 8086:8086 -p ...
- Ubuntu 虚拟机环境安装配置指南
1. 安装Ubuntu到虚拟机. 到 Ubuntu 上下载桌面版iso文件,加载到虚拟机,开始安装,傻瓜式操作不用多说.2. 调整屏幕分辨率. 虚拟机软件我是用的virtual box,在工具栏上设备 ...
- jenkins安装详细教程
一.jenkins简介 jenkins是一个开源的软件项目,是基于java开发的一种持续集成工具,用于监控持续重复的工作,旨在提供一个开放易用的软件平台,使软件的持续集成变成可能. 1.持续的软件版本 ...
- ubuntu docker的安装和使用
Docker CE for Ubuntu Docker CE for Ubuntu is the best way to install the Docker platform on Ubuntu L ...
- Ubuntu Docker 简单安装 GitLab
相关博文: Ubuntu 简单安装 Docker Ubuntu 简单安装和配置 GitLab 服务器版本 Ubuntu 16.04 LTS. 1. 安装和配置 安装命令: sudo docker ru ...
- docker jenkins安装(一)
https://hub.docker.com/r/jenkins/jenkins jenkins的docker官方镜像地址 https://jenkins.io/ jenkins官方网站 环境: ...
- Ubuntu VMware Tools安装详细过程(非常靠谱)
说明:该篇博客是博主一字一码编写的,实属不易,请尊重原创,谢谢大家! 一.前言 VMware Ubuntu安装以及详细过程:https://blog.csdn.net/qq_41782425/arti ...
随机推荐
- springboot中springAOP的使用
<dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring- ...
- c++json构建与解析组件 RapidJSON 没用过永远不会知道有多好用
参考资料: 官方文档 推荐[腾讯RapidJSON]学习笔记 原理请参考以上资料 构建json Document doc; Document::AllocatorType &allocator ...
- HDU 4417
题意略. 思路: 仔细思考这个题目会发现,它其实是要你查询两次,第一是要规定l,r的范围,第二是要在范围内查询小于等于H的个数.所以有的人说要用主席树. 现在,如果我们能省去范围内对h的查询呢?也就是 ...
- Hello World 之旅
本文记录对于下面 `hello.c` 程序在 Linux 上一次运行系统所发生的事情,内容来源于 CSAPP 第一章. #include <stdio.h> int main(int ar ...
- (五十四)c#Winform自定义控件-仪表盘
前提 入行已经7,8年了,一直想做一套漂亮点的自定义控件,于是就有了本系列文章. GitHub:https://github.com/kwwwvagaa/NetWinformControl 码云:ht ...
- Linux系统简介以及基本操作(一)
Linux简介(操作系统) Linux发展史(了解) Linux出现于1991年,是由芬兰赫尔辛基大学学生李纳斯·托瓦兹(Linus Torvalds)偶然发现的,他当时是为了方便下载学校网站的一些视 ...
- 洛谷 P1070 道路游戏 DP
P1070 道路游戏 题意: 有一个环,环上有n个工厂,每个工厂可以生产价格为x的零钱收割机器人,每个机器人在购买后可以沿着环最多走p条边,一秒走一条,每条边不同时间上出现的金币是不同的,问如何安排购 ...
- 关于斐波那契数列的一些恒等式 模板 牛客OI测试赛 A 斐波拉契
牛客A 斐波拉契 链接:https://www.nowcoder.com/acm/contest/181/A来源:牛客网 设f[i]表示斐波那契数论的第i项 f[1]=1,f[2] =1,f[i] = ...
- 关于Ubunto在VMwark中无法全屏。
1.右键点击Ubunto桌面,进入终端 输入: 1.sudo apt-get install open-vm* 安装依赖项 2.sudo apt-get install open-vm-tools ...
- python 整型、字符串常用方法、for循环
整型--int 定义:用于比较和计算 python2和python3: python2:python2中油int(整型)和long(长整型):1231312L+ 进制转换: 十进制转二进制:正除2,获 ...