【實戰練習】經過docker部署jenkins

jenkins官網 :https://jenkins.io/

拉取jenkins   

Official Jenkins Docker image


    
    
    
    
[root@ip-172-31-16-58 ec2-user]# docker pull jenkins/jenkinsUsing default tag: latestlatest: Pulling from jenkins/jenkins06b22ddb1913: Pull complete336c28b408ed: Pull complete1f3e6b8d80c3: Pull complete5ccc640979f6: Pull complete14eaa20184e6: Pull complete19a8522e2399: Pull complete39ba9d7befca: Pull complete1f81f3143db2: Pull complete2034c15120cd: Pull completecb9c7784507a: Pull complete160eb3637188: Pull complete6f0079684645: Pull completed03cc51cd013: Pull complete5c83a5102435: Pull completed1615ed88d09: Pull complete184c2f70a0cf: Pull complete468b123e967f: Pull completef1ae15a4cfc0: Pull complete02f7a795bd75: Pull completebdac05821dbe: Pull completeDigest: sha256:30f648f79d447aab092a1a8a2025ee90e257fc03245796a89fb8ffac638259eeStatus: Downloaded newer image for jenkins/jenkins:latest

操做手冊:
https://github.com/jenkinsci/docker/blob/master/README.md


   
   
   
   
  1. --volume-driver string Optional volume driver for the container
docker run 命令詳細文檔[root@ip-172-31-16-58 ec2-user]# docker run --helpUsage: docker run [OPTIONS] IMAGE [COMMAND] [ARG...]Run a command in a new containerOptions: --add-host list Add a custom host-to-IP mapping (host:ip) (default []) -a, --attach list Attach to STDIN, STDOUT or STDERR (default []) --blkio-weight uint16 Block IO (relative weight), between 10 and 1000, or 0 to disable (default 0) --blkio-weight-device weighted-device Block IO weight (relative device weight) (default []) --cap-add list Add Linux capabilities (default []) --cap-drop list Drop Linux capabilities (default []) --cgroup-parent string Optional parent cgroup for the container --cidfile string Write the container ID to the file --cpu-count int CPU count (Windows only) --cpu-percent int CPU percent (Windows only) --cpu-period int Limit CPU CFS (Completely Fair Scheduler) period --cpu-quota int Limit CPU CFS (Completely Fair Scheduler) quota --cpu-rt-period int Limit CPU real-time period in microseconds --cpu-rt-runtime int Limit CPU real-time runtime in microseconds -c, --cpu-shares int CPU shares (relative weight) //用於給運行在容器中的全部進程分配CPU的shares值。這是一個相對權重,實際的處理速度還與宿主機CPU相關 --cpus decimal Number of CPUs (default 0.000) --cpuset-cpus string CPUs in which to allow execution (0-3, 0,1) --cpuset-mems string MEMs in which to allow execution (0-3, 0,1) --credentialspec string Credential spec for managed service account (Windows only) -d, --detach Run container in background and print container ID --detach-keys string Override the key sequence for detaching a container --device list Add a host device to the container (default []) --device-read-bps throttled-device Limit read rate (bytes per second) from a device (default []) --device-read-iops throttled-device Limit read rate (IO per second) from a device (default []) --device-write-bps throttled-device Limit write rate (bytes per second) to a device (default []) --device-write-iops throttled-device Limit write rate (IO per second) to a device (default []) --disable-content-trust Skip image verification (default true) --dns list Set custom DNS servers (default []) --dns-option list Set DNS options (default []) --dns-search list Set custom DNS search domains (default []) --entrypoint string Overwrite the default ENTRYPOINT of the image -e, --env list Set environment variables (default []) --env-file list Read in a file of environment variables (default []) --expose list Expose a port or a range of ports (default []) --group-add list Add additional groups to join (default []) --health-cmd string Command to run to check health --health-interval duration Time between running the check (ns|us|ms|s|m|h) (default 0s) --health-retries int Consecutive failures needed to report unhealthy --health-timeout duration Maximum time to allow one check to run (ns|us|ms|s|m|h) (default 0s) --help Print usage -h, --hostname string Container host name --init Run an init inside the container that forwards signals and reaps processes --init-path string Path to the docker-init binary -i, --interactive Keep STDIN open even if not attached //保持輸入打開即便不鏈接 即選擇交互模式,始終保持輸入流開放 --io-maxbandwidth string Maximum IO bandwidth limit for the system drive (Windows only) --io-maxiops uint Maximum IOps limit for the system drive (Windows only) --ip string Container IPv4 address (e.g. 172.30.100.104) --ip6 string Container IPv6 address (e.g. 2001:db8::33) --ipc string IPC namespace to use --isolation string Container isolation technology --kernel-memory string Kernel memory limit -l, --label list Set meta data on a container (default []) --label-file list Read in a line delimited file of labels (default []) --link list Add link to another container (default []) --link-local-ip list Container IPv4/IPv6 link-local addresses (default []) --log-driver string Logging driver for the container --log-opt list Log driver options (default []) --mac-address string Container MAC address (e.g. 92:d0:c6:0a:29:33) -m, --memory string Memory limit //限制容器爲全部進程分配的內存總量 --memory-reservation string Memory soft limit --memory-swap string Swap limit equal to memory plus swap: '-1' to enable unlimited swap --memory-swappiness int Tune container memory swappiness (0 to 100) (default -1) --name string Assign a name to the container --network string Connect a container to a network (default "default") --network-alias list Add network-scoped alias for the container (default []) --no-healthcheck Disable any container-specified HEALTHCHECK --oom-kill-disable Disable OOM Killer --oom-score-adj int Tune host's OOM preferences (-1000 to 1000) --pid string PID namespace to use --pids-limit int Tune container pids limit (set -1 for unlimited) --privileged Give extended privileges to this container -p, --publish list Publish a container's port(s) to the host (default []) //端口映射到本機 將容器的端口暴漏給宿主機的端口 -P, --publish-all Publish all exposed ports to random ports --read-only Mount the container's root filesystem as read only --restart string Restart policy to apply when a container exits (default "no") --rm Automatically remove the container when it exits --runtime string Runtime to use for this container --security-opt list Security Options (default []) --shm-size string Size of /dev/shm, default value is 64MB --sig-proxy Proxy received signals to the process (default true) --stop-signal string Signal to stop a container, SIGTERM by default (default "SIGTERM") --stop-timeout int Timeout (in seconds) to stop a container --storage-opt list Storage driver options for the container (default []) --sysctl map Sysctl options (default map[]) --tmpfs list Mount a tmpfs directory (default []) -t, --tty Allocate a pseudo-TTY //分配一個僞終端,通常兩個參數結合是使用 -it,就能夠在容器中利用打開的僞終端進行交互操做 --ulimit ulimit Ulimit options (default []) -u, --user string Username or UID (format: <name|uid>[:<group|gid>]) --userns string User namespace to use --uts string UTS namespace to use -v, --volume list Bind mount a volume (default []) //用戶掛載一個volume 能夠用多個-v掛載讀個 。volume的格式爲[host-dir]:[container-dir]:[rw|ro] --volumes-from list Mount volumes from the specified container(s) (default []) -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是相同的,而且一一對應。

運行記錄 
   
   
   
   
[root@ip-172-31-16-58 ec2-user]# docker run -p 8080:8080 -p 50000:50000 -v jenkins_home:/var/jenkins_home jenkins/jenkinsdocker: 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.[root@ip-172-31-16-58 ec2-user]# docker run -p 8080:8081 -p 50000:50000 -v jenkins_home:/var/jenkins_home jenkins/jenkinsdocker: 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.[root@ip-172-31-16-58 ec2-user]# docker run -p 8081:8080 -p 50000:50000 -v jenkins_home:/var/jenkins_home jenkins/jenkinsRunning from: /usr/share/jenkins/jenkins.warwebroot: EnvVars.masterEnvVars.get("JENKINS_HOME")Jul 25, 2017 8:21:05 AM Main deleteWinstoneTempContentsWARNING: Failed to delete the temporary Winstone file /tmp/winstone/jenkins.warJul 25, 2017 8:21:06 AM org.eclipse.jetty.util.log.Log initializedINFO: Logging initialized @1202ms to org.eclipse.jetty.util.log.JavaUtilLogJul 25, 2017 8:21:06 AM winstone.Logger logInternalINFO: Beginning extraction from war fileJul 25, 2017 8:21:07 AM org.eclipse.jetty.server.handler.ContextHandler setContextPathWARNING: Empty contextPathJul 25, 2017 8:21:08 AM org.eclipse.jetty.server.Server doStartINFO: jetty-9.4.z-SNAPSHOTJul 25, 2017 8:21:08 AM org.eclipse.jetty.webapp.StandardDescriptorProcessor visitServletINFO: NO JSP Support for /, did not find org.eclipse.jetty.jsp.JettyJspServletJul 25, 2017 8:21:08 AM org.eclipse.jetty.server.session.DefaultSessionIdManager doStartINFO: DefaultSessionIdManager workerName=node0Jul 25, 2017 8:21:08 AM org.eclipse.jetty.server.session.DefaultSessionIdManager doStartINFO: No SessionScavenger set, using defaultsJul 25, 2017 8:21:08 AM org.eclipse.jetty.server.session.HouseKeeper startScavengingINFO: Scavenging every 660000msJenkins home directory: /var/jenkins_home found at: EnvVars.masterEnvVars.get("JENKINS_HOME")Jul 25, 2017 8:21:09 AM org.eclipse.jetty.server.handler.ContextHandler doStartINFO: Started w.@62e70ea3{/,file:///var/jenkins_home/war/,AVAILABLE}{/var/jenkins_home/war}Jul 25, 2017 8:21:09 AM org.eclipse.jetty.server.AbstractConnector doStartINFO: Started ServerConnector@25ddbbbb{HTTP/1.1,[http/1.1]}{0.0.0.0:8080}Jul 25, 2017 8:21:09 AM org.eclipse.jetty.server.Server doStartINFO: Started @4942msJul 25, 2017 8:21:09 AM winstone.Logger logInternalINFO: Winstone Servlet Engine v4.0 running: controlPort=disabledJul 25, 2017 8:21:10 AM jenkins.InitReactorRunner$1 onAttainedINFO: Started initializationJul 25, 2017 8:21:10 AM jenkins.InitReactorRunner$1 onAttainedINFO: Listed all pluginsJul 25, 2017 8:21:13 AM jenkins.InitReactorRunner$1 onAttainedINFO: Prepared all pluginsJul 25, 2017 8:21:13 AM jenkins.InitReactorRunner$1 onAttainedINFO: Started all pluginsJul 25, 2017 8:21:13 AM jenkins.InitReactorRunner$1 onAttainedINFO: Augmented all extensionsJul 25, 2017 8:21:15 AM jenkins.InitReactorRunner$1 onAttainedINFO: Loaded all jobsJul 25, 2017 8:21:15 AM hudson.model.AsyncPeriodicWork$1 runINFO: Started Download metadataJul 25, 2017 8:21:16 AM jenkins.util.groovy.GroovyHookScript executeINFO: Executing /var/jenkins_home/init.groovy.d/tcp-slave-agent-port.groovyJul 25, 2017 8:21:16 AM jenkins.InitReactorRunner$1 onAttainedINFO: Completed initializationJul 25, 2017 8:21:17 AM org.springframework.context.support.AbstractApplicationContext prepareRefreshINFO: Refreshing org.springframework.web.context.support.StaticWebApplicationContext@6f1a6ab9: display name [Root WebApplicationContext]; startup date [Tue Jul 25 08:21:17 UTC 2017]; root of context hierarchyJul 25, 2017 8:21:17 AM org.springframework.context.support.AbstractApplicationContext obtainFreshBeanFactoryINFO: Bean factory for application context [org.springframework.web.context.support.StaticWebApplicationContext@6f1a6ab9]: org.springframework.beans.factory.support.DefaultListableBeanFactory@70246b4fJul 25, 2017 8:21:17 AM org.springframework.beans.factory.support.DefaultListableBeanFactory preInstantiateSingletonsINFO: Pre-instantiating singletons in org.springframework.beans.factory.support.DefaultListableBeanFactory@70246b4f: defining beans [authenticationManager]; root of factory hierarchyJul 25, 2017 8:21:18 AM org.springframework.context.support.AbstractApplicationContext prepareRefreshINFO: Refreshing org.springframework.web.context.support.StaticWebApplicationContext@3519c206: display name [Root WebApplicationContext]; startup date [Tue Jul 25 08:21:18 UTC 2017]; root of context hierarchyJul 25, 2017 8:21:18 AM org.springframework.context.support.AbstractApplicationContext obtainFreshBeanFactoryINFO: Bean factory for application context [org.springframework.web.context.support.StaticWebApplicationContext@3519c206]: org.springframework.beans.factory.support.DefaultListableBeanFactory@5ec0f5c8Jul 25, 2017 8:21:18 AM org.springframework.beans.factory.support.DefaultListableBeanFactory preInstantiateSingletonsINFO: Pre-instantiating singletons in org.springframework.beans.factory.support.DefaultListableBeanFactory@5ec0f5c8: defining beans [filter,legacy]; root of factory hierarchyJul 25, 2017 8:21:19 AM jenkins.install.SetupWizard initINFO:***************************************************************************************************************************************************************************************Jenkins initial setup is required. An admin user has been created and a password generated.Please use the following password to proceed to installation:89389c1eefaf48e3a9a7caa94abbc59dThis may also be found at: /var/jenkins_home/secrets/initialAdminPassword***************************************************************************************************************************************************************************************Jul 25, 2017 8:21:23 AM hudson.model.UpdateSite updateDataINFO: Obtained the latest update center data file for UpdateSource defaultJul 25, 2017 8:21:23 AM hudson.model.DownloadService$Downloadable loadINFO: Obtained the updated data file for hudson.tasks.Maven.MavenInstallerJul 25, 2017 8:21:25 AM hudson.model.DownloadService$Downloadable loadINFO: Obtained the updated data file for hudson.tools.JDKInstallerJul 25, 2017 8:21:25 AM hudson.model.AsyncPeriodicWork$1 runINFO: Finished Download metadata. 9,840 msJul 25, 2017 8:21:25 AM hudson.model.UpdateSite updateDataINFO: Obtained the latest update center data file for UpdateSource defaultJul 25, 2017 8:21:25 AM hudson.WebAppMain$3 runINFO: Jenkins is fully up and running--> setting agent port for jnlp--> setting agent port for jnlp... done


安裝完成
相關文章
相關標籤/搜索