【实战练习】通过docker部署jenkins

jenkins官网 :https://jenkins.io/



拉取jenkins

Official Jenkins Docker image

  1. [[email protected]-172-31-16-58 ec2-user]# docker pull jenkins/jenkins
  2. Using default tag: latest
  3. latest: Pulling from jenkins/jenkins
  4. 06b22ddb1913: Pull complete
  5. 336c28b408ed: Pull complete
  6. 1f3e6b8d80c3: Pull complete
  7. 5ccc640979f6: Pull complete
  8. 14eaa20184e6: Pull complete
  9. 19a8522e2399: Pull complete
  10. 39ba9d7befca: Pull complete
  11. 1f81f3143db2: Pull complete
  12. 2034c15120cd: Pull complete
  13. cb9c7784507a: Pull complete
  14. 160eb3637188: Pull complete
  15. 6f0079684645: Pull complete
  16. d03cc51cd013: Pull complete
  17. 5c83a5102435: Pull complete
  18. d1615ed88d09: Pull complete
  19. 184c2f70a0cf: Pull complete
  20. 468b123e967f: Pull complete
  21. f1ae15a4cfc0: Pull complete
  22. 02f7a795bd75: Pull complete
  23. bdac05821dbe: Pull complete
  24. Digest: sha256:30f648f79d447aab092a1a8a2025ee90e257fc03245796a89fb8ffac638259ee
  25. Status: Downloaded newer image for jenkins/jenkins:latest

操作手册:

https://github.com/jenkinsci/docker/blob/master/README.md

  1. docker run 命令详细文档
  2. [[email protected]-172-31-16-58 ec2-user]# docker run --help
  3. Usage: docker run [OPTIONS] IMAGE [COMMAND] [ARG...]
  4. Run a command in a new container
  5. Options:
  6. --add-host list Add a custom host-to-IP mapping (host:ip) (default [])
  7. -a, --attach list Attach to STDIN, STDOUT or STDERR (default [])
  8. --blkio-weight uint16 Block IO (relative weight), between 10 and 1000, or 0 to disable (default 0)
  9. --blkio-weight-device weighted-device Block IO weight (relative device weight) (default [])
  10. --cap-add list Add Linux capabilities (default [])
  11. --cap-drop list Drop Linux capabilities (default [])
  12. --cgroup-parent string Optional parent cgroup for the container
  13. --cidfile string Write the container ID to the file
  14. --cpu-count int CPU count (Windows only)
  15. --cpu-percent int CPU percent (Windows only)
  16. --cpu-period int Limit CPU CFS (Completely Fair Scheduler) period
  17. --cpu-quota int Limit CPU CFS (Completely Fair Scheduler) quota
  18. --cpu-rt-period int Limit CPU real-time period in microseconds
  19. --cpu-rt-runtime int Limit CPU real-time runtime in microseconds
  20. -c, --cpu-shares int CPU shares (relative weight) //用于给运行在容器中的所有进程分配CPU的shares值。这是一个相对权重,实际的处理速度还与宿主机CPU相关
  21. --cpus decimal Number of CPUs (default 0.000)
  22. --cpuset-cpus string CPUs in which to allow execution (0-3, 0,1)
  23. --cpuset-mems string MEMs in which to allow execution (0-3, 0,1)
  24. --credentialspec string Credential spec for managed service account (Windows only)
  25. -d, --detach Run container in background and print container ID
  26. --detach-keys string Override the key sequence for detaching a container
  27. --device list Add a host device to the container (default [])
  28. --device-read-bps throttled-device Limit read rate (bytes per second) from a device (default [])
  29. --device-read-iops throttled-device Limit read rate (IO per second) from a device (default [])
  30. --device-write-bps throttled-device Limit write rate (bytes per second) to a device (default [])
  31. --device-write-iops throttled-device Limit write rate (IO per second) to a device (default [])
  32. --disable-content-trust Skip image verification (default true)
  33. --dns list Set custom DNS servers (default [])
  34. --dns-option list Set DNS options (default [])
  35. --dns-search list Set custom DNS search domains (default [])
  36. --entrypoint string Overwrite the default ENTRYPOINT of the image
  37. -e, --env list Set environment variables (default [])
  38. --env-file list Read in a file of environment variables (default [])
  39. --expose list Expose a port or a range of ports (default [])
  40. --group-add list Add additional groups to join (default [])
  41. --health-cmd string Command to run to check health
  42. --health-interval duration Time between running the check (ns|us|ms|s|m|h) (default 0s)
  43. --health-retries int Consecutive failures needed to report unhealthy
  44. --health-timeout duration Maximum time to allow one check to run (ns|us|ms|s|m|h) (default 0s)
  45. --help Print usage
  46. -h, --hostname string Container host name
  47. --init Run an init inside the container that forwards signals and reaps processes
  48. --init-path string Path to the docker-init binary
  49. -i, --interactive Keep STDIN open even if not attached //保持输入打开即使不连接 即选择交互模式,始终保持输入流开放
  50. --io-maxbandwidth string Maximum IO bandwidth limit for the system drive (Windows only)
  51. --io-maxiops uint Maximum IOps limit for the system drive (Windows only)
  52. --ip string Container IPv4 address (e.g. 172.30.100.104)
  53. --ip6 string Container IPv6 address (e.g. 2001:db8::33)
  54. --ipc string IPC namespace to use
  55. --isolation string Container isolation technology
  56. --kernel-memory string Kernel memory limit
  57. -l, --label list Set meta data on a container (default [])
  58. --label-file list Read in a line delimited file of labels (default [])
  59. --link list Add link to another container (default [])
  60. --link-local-ip list Container IPv4/IPv6 link-local addresses (default [])
  61. --log-driver string Logging driver for the container
  62. --log-opt list Log driver options (default [])
  63. --mac-address string Container MAC address (e.g. 92:d0:c6:0a:29:33)
  64. -m, --memory string Memory limit //限制容器为所有进程分配的内存总量
  65. --memory-reservation string Memory soft limit
  66. --memory-swap string Swap limit equal to memory plus swap: ‘-1‘ to enable unlimited swap
  67. --memory-swappiness int Tune container memory swappiness (0 to 100) (default -1)
  68. --name string Assign a name to the container
  69. --network string Connect a container to a network (default "default")
  70. --network-alias list Add network-scoped alias for the container (default [])
  71. --no-healthcheck Disable any container-specified HEALTHCHECK
  72. --oom-kill-disable Disable OOM Killer
  73. --oom-score-adj int Tune host‘s OOM preferences (-1000 to 1000)
  74. --pid string PID namespace to use
  75. --pids-limit int Tune container pids limit (set -1 for unlimited)
  76. --privileged Give extended privileges to this container
  77. -p, --publish list Publish a container‘s port(s) to the host (default []) //端口映射到本机 将容器的端口暴漏给宿主机的端口
  78. -P, --publish-all Publish all exposed ports to random ports
  79. --read-only Mount the container‘s root filesystem as read only
  80. --restart string Restart policy to apply when a container exits (default "no")
  81. --rm Automatically remove the container when it exits
  82. --runtime string Runtime to use for this container
  83. --security-opt list Security Options (default [])
  84. --shm-size string Size of /dev/shm, default value is 64MB
  85. --sig-proxy Proxy received signals to the process (default true)
  86. --stop-signal string Signal to stop a container, SIGTERM by default (default "SIGTERM")
  87. --stop-timeout int Timeout (in seconds) to stop a container
  88. --storage-opt list Storage driver options for the container (default [])
  89. --sysctl map Sysctl options (default map[])
  90. --tmpfs list Mount a tmpfs directory (default [])
  91. -t, --tty Allocate a pseudo-TTY //分配一个伪终端,一般两个参数结合是使用 -it,就可以在容器中利用打开的伪终端进行交互操作
  92. --ulimit ulimit Ulimit options (default [])
  93. -u, --user string Username or UID (format: <name|uid>[:<group|gid>])
  94. --userns string User namespace to use
  95. --uts string UTS namespace to use
  96. -v, --volume list Bind mount a volume (default []) //用户挂载一个volume 可以用多个-v挂载读个 。volume的格式为[host-dir]:[container-dir]:[rw|ro]
  97. --volume-driver string Optional volume driver for the container
  98. --volumes-from list Mount volumes from the specified container(s) (default [])
  99. -w, --workdir string Working directory inside the container

注释:volume:

LVM几个基本概念

*物理存储介质(PhysicalStorageMedia):指系统的物理存储设备:磁盘,如:/dev/hda、/dev/sda等,是存储系统最底层的存储单元

*物理卷(Physical Volume,PV):指磁盘分区或从逻辑上与磁盘分区具有同样功能的设备(如RAID),是LVM的基本存储逻辑块,但和基本的物理存储介质(如分区、磁盘等)比较,却包含有与LVM相关的管理参数。

*物理块(Physical Extent,PE):每一个物理卷PV被划分为称为PE(Physical Extents)的基本单元,具有唯一编号的PE是可以被LVM寻址的最小单元。PE的大小是可配置的,默认为4MB。所以物理卷(PV)由大小等同的基本单元PE组成。

*卷组(Volume Group,VG):类似于非LVM系统中的物理磁盘,其由一个或多个物理卷PV组成。可以在卷组上创建一个或多个LV(逻辑卷)。

*逻辑卷(Logical Volume,LV):类似于非LVM系统中的磁盘分区,逻辑卷建立在卷组VG之上。在逻辑卷LV之上可以建立文件系统(比如/home或者/usr等)。

*逻辑块(Logical Extent,LE):逻辑卷LV也被划分为可被寻址的基本单位,称为LE。在同一个卷组中,LE的大小和PE是相同的,并且一一对应。

来源: http://doc.okbase.net/sammyliu/archive/118273.html

运行记录

  1. [[email protected]-172-31-16-58 ec2-user]# docker run -p 8080:8080 -p 50000:50000 -v jenkins_home:/var/jenkins_home jenkins/jenkins
  2. docker: Error response from daemon: driver failed programming external connectivity on endpoint elegant_darwin (1597358b18b14e84246118d59c368cd17fb7eee2928c2e918305ca511bcae754): Error starting userland proxy: listen tcp 0.0.0.0:8080: bind: address already in use.
  3. [[email protected]-172-31-16-58 ec2-user]# docker run -p 8080:8081 -p 50000:50000 -v jenkins_home:/var/jenkins_home jenkins/jenkins
  4. docker: Error response from daemon: driver failed programming external connectivity on endpoint frosty_yonath (67bfcad0fa9e58200dbccd10ad69a1939fb70c128ab586dd23fc1608e6f33de7): Error starting userland proxy: listen tcp 0.0.0.0:8080: bind: address already in use.
  5. [[email protected]-172-31-16-58 ec2-user]# docker run -p 8081:8080 -p 50000:50000 -v jenkins_home:/var/jenkins_home jenkins/jenkins
  6. Running from: /usr/share/jenkins/jenkins.war
  7. webroot: EnvVars.masterEnvVars.get("JENKINS_HOME")
  8. Jul 25, 2017 8:21:05 AM Main deleteWinstoneTempContents
  9. WARNING: Failed to delete the temporary Winstone file /tmp/winstone/jenkins.war
  10. Jul 25, 2017 8:21:06 AM org.eclipse.jetty.util.log.Log initialized
  11. INFO: Logging initialized @1202ms to org.eclipse.jetty.util.log.JavaUtilLog
  12. Jul 25, 2017 8:21:06 AM winstone.Logger logInternal
  13. INFO: Beginning extraction from war file
  14. Jul 25, 2017 8:21:07 AM org.eclipse.jetty.server.handler.ContextHandler setContextPath
  15. WARNING: Empty contextPath
  16. Jul 25, 2017 8:21:08 AM org.eclipse.jetty.server.Server doStart
  17. INFO: jetty-9.4.z-SNAPSHOT
  18. Jul 25, 2017 8:21:08 AM org.eclipse.jetty.webapp.StandardDescriptorProcessor visitServlet
  19. INFO: NO JSP Support for /, did not find org.eclipse.jetty.jsp.JettyJspServlet
  20. Jul 25, 2017 8:21:08 AM org.eclipse.jetty.server.session.DefaultSessionIdManager doStart
  21. INFO: DefaultSessionIdManager workerName=node0
  22. Jul 25, 2017 8:21:08 AM org.eclipse.jetty.server.session.DefaultSessionIdManager doStart
  23. INFO: No SessionScavenger set, using defaults
  24. Jul 25, 2017 8:21:08 AM org.eclipse.jetty.server.session.HouseKeeper startScavenging
  25. INFO: Scavenging every 660000ms
  26. Jenkins home directory: /var/jenkins_home found at: EnvVars.masterEnvVars.get("JENKINS_HOME")
  27. Jul 25, 2017 8:21:09 AM org.eclipse.jetty.server.handler.ContextHandler doStart
  28. INFO: Started w[email protected]62e70ea3{/,file:///var/jenkins_home/war/,AVAILABLE}{/var/jenkins_home/war}
  29. Jul 25, 2017 8:21:09 AM org.eclipse.jetty.server.AbstractConnector doStart
  30. INFO: Started [email protected]{HTTP/1.1,[http/1.1]}{0.0.0.0:8080}
  31. Jul 25, 2017 8:21:09 AM org.eclipse.jetty.server.Server doStart
  32. INFO: Started @4942ms
  33. Jul 25, 2017 8:21:09 AM winstone.Logger logInternal
  34. INFO: Winstone Servlet Engine v4.0 running: controlPort=disabled
  35. Jul 25, 2017 8:21:10 AM jenkins.InitReactorRunner$1 onAttained
  36. INFO: Started initialization
  37. Jul 25, 2017 8:21:10 AM jenkins.InitReactorRunner$1 onAttained
  38. INFO: Listed all plugins
  39. Jul 25, 2017 8:21:13 AM jenkins.InitReactorRunner$1 onAttained
  40. INFO: Prepared all plugins
  41. Jul 25, 2017 8:21:13 AM jenkins.InitReactorRunner$1 onAttained
  42. INFO: Started all plugins
  43. Jul 25, 2017 8:21:13 AM jenkins.InitReactorRunner$1 onAttained
  44. INFO: Augmented all extensions
  45. Jul 25, 2017 8:21:15 AM jenkins.InitReactorRunner$1 onAttained
  46. INFO: Loaded all jobs
  47. Jul 25, 2017 8:21:15 AM hudson.model.AsyncPeriodicWork$1 run
  48. INFO: Started Download metadata
  49. Jul 25, 2017 8:21:16 AM jenkins.util.groovy.GroovyHookScript execute
  50. INFO: Executing /var/jenkins_home/init.groovy.d/tcp-slave-agent-port.groovy
  51. Jul 25, 2017 8:21:16 AM jenkins.InitReactorRunner$1 onAttained
  52. INFO: Completed initialization
  53. Jul 25, 2017 8:21:17 AM org.springframework.context.support.AbstractApplicationContext prepareRefresh
  54. INFO: Refreshing org.springframework.web.context.support.[email protected]: display name [Root WebApplicationContext]; startup date [Tue Jul 25 08:21:17 UTC 2017]; root of context hierarchy
  55. Jul 25, 2017 8:21:17 AM org.springframework.context.support.AbstractApplicationContext obtainFreshBeanFactory
  56. INFO: Bean factory for application context [org.springframework.web.context.support.[email protected]]: org.springframework.beans.factory.support.[email protected]
  57. Jul 25, 2017 8:21:17 AM org.springframework.beans.factory.support.DefaultListableBeanFactory preInstantiateSingletons
  58. INFO: Pre-instantiating singletons in org.springframework.beans.factory.support.[email protected]: defining beans [authenticationManager]; root of factory hierarchy
  59. Jul 25, 2017 8:21:18 AM org.springframework.context.support.AbstractApplicationContext prepareRefresh
  60. INFO: Refreshing org.springframework.web.context.support.[email protected]: display name [Root WebApplicationContext]; startup date [Tue Jul 25 08:21:18 UTC 2017]; root of context hierarchy
  61. Jul 25, 2017 8:21:18 AM org.springframework.context.support.AbstractApplicationContext obtainFreshBeanFactory
  62. INFO: Bean factory for application context [org.springframework.web.context.support.[email protected]]: org.springframework.beans.factory.support.[email protected]
  63. Jul 25, 2017 8:21:18 AM org.springframework.beans.factory.support.DefaultListableBeanFactory preInstantiateSingletons
  64. INFO: Pre-instantiating singletons in org.springframework.beans.factory.support.[email protected]: defining beans [filter,legacy]; root of factory hierarchy
  65. Jul 25, 2017 8:21:19 AM jenkins.install.SetupWizard init
  66. INFO:
  67. *************************************************************
  68. *************************************************************
  69. *************************************************************
  70. Jenkins initial setup is required. An admin user has been created and a password generated.
  71. Please use the following password to proceed to installation:
  72. 89389c1eefaf48e3a9a7caa94abbc59d
  73. This may also be found at: /var/jenkins_home/secrets/initialAdminPassword
  74. *************************************************************
  75. *************************************************************
  76. *************************************************************
  77. Jul 25, 2017 8:21:23 AM hudson.model.UpdateSite updateData
  78. INFO: Obtained the latest update center data file for UpdateSource default
  79. Jul 25, 2017 8:21:23 AM hudson.model.DownloadService$Downloadable load
  80. INFO: Obtained the updated data file for hudson.tasks.Maven.MavenInstaller
  81. Jul 25, 2017 8:21:25 AM hudson.model.DownloadService$Downloadable load
  82. INFO: Obtained the updated data file for hudson.tools.JDKInstaller
  83. Jul 25, 2017 8:21:25 AM hudson.model.AsyncPeriodicWork$1 run
  84. INFO: Finished Download metadata. 9,840 ms
  85. Jul 25, 2017 8:21:25 AM hudson.model.UpdateSite updateData
  86. INFO: Obtained the latest update center data file for UpdateSource default
  87. Jul 25, 2017 8:21:25 AM hudson.WebAppMain$3 run
  88. INFO: Jenkins is fully up and running
  89. --> setting agent port for jnlp
  90. --> setting agent port for jnlp... done

安装完成

null

时间: 2024-11-10 18:27:27

【实战练习】通过docker部署jenkins的相关文章

docker部署Jenkins,以及在Jenkins中使用宿主机的docker/docker-compose命令

使用最新的官方镜像jenkins/jenkins 第一次使用的docker部署jenkins的时候,出现了两个问题: 1.因为用户权限问题挂载/home/jenkins/data到/var/jenkins_home挂载不了.后面通过修改data目录的所属用户可以解决,即在容器下查询用户id(1000),然后把data改成同样的用户id 2.即便挂载docker命名和docker.sock,也修改了相应的权限,仍存在libltdl7没有权限读取.当然好像也不影响使用,只是在容器里面执行docker

docker 部署 jenkins

建议使用的Docker映像是jenkinsci/blueocean image(来自 the Docker Hub repository). 该镜像包含当前的长期支持 (LTS) 的Jenkins版本 (可以投入使用) ,捆绑了所有Blue Ocean插件和功能. 部署方法: docker run -u root --name jenkins -d -p 8080:8080 -p 50000:50000 -v jenkins-data:/var/jenkins_home -v /var/run/

Ubuntu系统下基于docker部署Jenkins环境

本文是在ubuntu环境下安装jenkins,jenkins运行在docker容器中, 至于docker如何安装,请参考https://www.cnblogs.com/xingyunqiu/p/11584066.html Jenkins官网文档:https://jenkins.io/zh/doc/ 使用命令从镜像仓库拉取指定文件,我这里用的是jenkins:lts这个版本:如果需要其他版本 注意,由于我是基于docker容器化部署Jenkins,所以不需要安装jdk环境 sudo docker

使用Docker部署Jenkins

由于Docker的普及,刚好目前团队需要Jenkins自动发布环境,于是决定把使用Docker来运行Jenkins服务. 环境:Centos7 安装Docker: systemctl install docker 运行Docker systemctl start docker 拉镜像: docker pull docker.io/jenkinsci/jenkins run镜像: docker run -i -t -d -p 1001:8080 -p 50000:50000 -v /home/ma

Docker的Jenkins Pipeline工作流

原文地址:http://www.youruncloud.com/blog/127.html 分享主题 一个软件产品的开发周期中,尤其是敏捷开发,持续集成和持续部署是必不可少的环节,而随着产品的丰富,模块的增多.随即带来了更加多的问题,各模块间编译环境的准备,编译复杂,耗时增加,还需要专人去负责这个流程.而Jenkins则可以很好的解决这个单一而容易出错的CI(持续集成)工作. Jenkins也存在着编译环境不隔离的问题,虽然可以通过集群的方式解决,可是需要为每种环境甚至是一种语言的不同版本准备多

docker与jenkins的自动化CI/CD流水线实战

docker与jenkins的自动化CI/CD流水线实战 在互联网时代,对于每一家公司,软件开发和发布的重要性不言而喻,目前已经形成一套标准的流程,最重要的组成部分就是持续集成(CI)及持续部署.交付(CD).本文基于Jenkins+Docker+Git实现一套CI自动化发布流程. 高效的CI/CD环境可以获得: ? 及时发现问题 ? 大幅度减少故障率 ? 加快迭代速度 ? 减少时间成本 一.发布流程设计 总结:开发===>提交代码到Git/Svn===>推送到Jenkins====>通

在Docker Centos上部署Jenkins(包含Jenkins汉化)

环境: 本机 - macOS 10.12.6 Docker - Docker Community Editoin_ Version 17.06.0-ce-mac19(安装步骤见另一篇) 使用的Docker镜像: centos (latest) 安装步骤: 1.新建并启动一个centos docker容器 tester_mac:~ $  docker run -itd --privileged --name=jenkins -p 4000:4000 centos /usr/sbin/init --

部署Jenkins+docker集成环境

环境: 主机(mac osx)和虚拟机(Ubuntu 16.04) mac osx系统,运行Jenkins Ubuntu16.04系统,运行docker(用Ubuntu14.04镜像创建一个docker) tips: 1.Jenkins运行在哪个环境都可以(这里运行在osx系统) 2.Jenkins创建的node(slave),launch slave agents on Unix machines via SSH(通过SSH远程登陆Unix,这里的Unix环境是用Ubuntu14.04镜像创建

docker下部署jenkins

Jenkins https://jenkins.io https://hub.docker.com/r/jenkins/jenkins/ 拉取镜像 #53上的docker jenkins #必须要给jenkins用户组1000权限 #jenkins:x:1000:1000::/home/jenkins:/bin/bash sudo docker run -itd -p 8080:8080 -p 50000:50000 --name jenkins --privileged=true --rest