私有倉庫已經搭建好了,先講解下環境java
個人docker registry在mesos slave 上,也就是以前的git
能夠看到私有的倉庫裏面已經有了3個鏡像,此次咱們要使用jenkins這個鏡像,這個鏡像主要包含了JAVA環境和一個tomcat工程,工程的webapps下是沒有東西的web
如今我在私有倉庫的機器上刪除全部的鏡像和容器docker
root@web2:/opt/dockerfiles# docker images REPOSITORY TAG IMAGE ID CREATED VIRTUAL SIZE root@web2:/opt/dockerfiles# docker ps -a CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
看看個人Dockerfileapache
root@web2:/opt/dockerfiles# pwd /opt/dockerfiles root@web2:/opt/dockerfiles# ls Dockerfile jenkins.war root@web2:/opt/dockerfiles# more Dockerfile FROM 172.16.126.129/jenkins MAINTAINER jastme #RUN apt-get install sysstat -y # #RUN apt-get install -y build-essential # #RUN apt-get install -y software-properties-common # #RUN apt-get install -y byobu curl git htop man unzip vim wget COPY jenkins.war /ywkj/tomcat/webapps/jenkins.war ENV JAVA_HOME=/opt/jdk1.7 ENV CLASSPATH=.:/opt/jdk1.7/lib/dt.jar:/opt/jdk1.7/lib/tools.jar ENV PATH $JAVA_HOME/bin:$CLASSPATH:$PATH EXPOSE 8080 ENTRYPOINT /ywkj/tomcat/bin/startup.sh && tail -F /ywkj/tomcat/logs/catalina.out
開始構建鏡像vim
咱們構建一個REPOSITORY爲jenkins tag爲test的鏡像tomcat
root@web2:/opt/dockerfiles# docker build -t="jenkins:test" . Sending build context to Docker daemon 69.02 MB Sending build context to Docker daemon Step 0 : FROM 172.16.126.129/jenkins Pulling repository 172.16.126.129/jenkins 0f90f20ed759: Download complete 58488e45273c: Download complete 25810b66099e: Download complete 6571ba684f54: Download complete 6ed49a73d8f0: Download complete c53777cbfc31: Download complete 56465e1e45d2: Download complete 9525990c1a59: Download complete 4b16211c9344: Download complete Status: Downloaded newer image for 172.16.126.129/jenkins:latest ---> 0f90f20ed759 Step 1 : MAINTAINER jastme ---> Running in 249047b08222 ---> 83c9d1880cbf Removing intermediate container 249047b08222 Step 2 : COPY jenkins.war /ywkj/tomcat/webapps/jenkins.war ---> 8ddb8a0d43d0 Removing intermediate container df861980347c Step 3 : ENV JAVA_HOME /opt/jdk1.7 ---> Running in 8d769e747d0f ---> 9612f02f92a0 Removing intermediate container 8d769e747d0f Step 4 : ENV CLASSPATH .:/opt/jdk1.7/lib/dt.jar:/opt/jdk1.7/lib/tools.jar ---> Running in 5a7e0eb0589d ---> 5cbeba873965 Removing intermediate container 5a7e0eb0589d Step 5 : ENV PATH $JAVA_HOME/bin:$CLASSPATH:$PATH ---> Running in df35ac988bd3 ---> a2d882bbae0f Removing intermediate container df35ac988bd3 Step 6 : EXPOSE 8080 ---> Running in 0af2fd672296 ---> 2074c2b72310 Removing intermediate container 0af2fd672296 Step 7 : ENTRYPOINT /ywkj/tomcat/bin/startup.sh && tail -F /ywkj/tomcat/logs/catalina.out ---> Running in 4115910e5c92 ---> 285b7399d473 Removing intermediate container 4115910e5c92 Successfully built 285b7399d473 root@web2:/opt/dockerfiles# docker images REPOSITORY TAG IMAGE ID CREATED VIRTUAL SIZE jenkins test 285b7399d473 22 seconds ago 720.1 MB 172.16.126.129/jenkins latest 0f90f20ed759 29 hours ago 651.1 MB
OK,已經構建好了,如今開始啓動容器app
root@web2:/opt/dockerfiles# docker run -d --restart=always -p 8080:8080 --name jenkins jenkins:test 9a563fb692b3d029c3e2dbdb201b8f2d7bba447525af5dbb24ed83e7fc4acbfd root@web2:/opt/dockerfiles# docker ps -a CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES 9a563fb692b3 jenkins:test "/bin/sh -c '/ywkj/t 5 seconds ago Up 3 seconds 0.0.0.0:8080->8080/tcp jenkins
已經成功啓動ssh
使用WEB測試curl
root@web2:/opt/dockerfiles# docker logs 9a563fb692b3 Tomcat started. Nov 25, 2016 9:14:54 AM org.apache.catalina.startup.VersionLoggerListener log INFO: Server version: Apache Tomcat/7.0.65 Nov 25, 2016 9:14:54 AM org.apache.catalina.startup.VersionLoggerListener log INFO: Server built: Oct 9 2015 08:36:58 UTC Nov 25, 2016 9:14:54 AM org.apache.catalina.startup.VersionLoggerListener log INFO: Server number: 7.0.65.0 Nov 25, 2016 9:14:54 AM org.apache.catalina.startup.VersionLoggerListener log INFO: OS Name: Linux Nov 25, 2016 9:14:54 AM org.apache.catalina.startup.VersionLoggerListener log INFO: OS Version: 4.2.0-27-generic Nov 25, 2016 9:14:54 AM org.apache.catalina.startup.VersionLoggerListener log INFO: Architecture: amd64 Nov 25, 2016 9:14:54 AM org.apache.catalina.startup.VersionLoggerListener log INFO: Java Home: /opt/jdk1.7/jre Nov 25, 2016 9:14:54 AM org.apache.catalina.startup.VersionLoggerListener log INFO: JVM Version: 1.7.0_67-b01 Nov 25, 2016 9:14:54 AM org.apache.catalina.startup.VersionLoggerListener log INFO: JVM Vendor: Oracle Corporation Nov 25, 2016 9:14:54 AM org.apache.catalina.startup.VersionLoggerListener log INFO: CATALINA_BASE: /ywkj/tomcat Nov 25, 2016 9:14:54 AM org.apache.catalina.startup.VersionLoggerListener log INFO: CATALINA_HOME: /ywkj/tomcat Nov 25, 2016 9:14:54 AM org.apache.catalina.startup.VersionLoggerListener log INFO: Command line argument: -Djava.util.logging.config.file=/ywkj/tomcat/conf/logging.properties Nov 25, 2016 9:14:54 AM org.apache.catalina.startup.VersionLoggerListener log INFO: Command line argument: -Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager Nov 25, 2016 9:14:54 AM org.apache.catalina.startup.VersionLoggerListener log INFO: Command line argument: -Djava.endorsed.dirs=/ywkj/tomcat/endorsed Nov 25, 2016 9:14:54 AM org.apache.catalina.startup.VersionLoggerListener log INFO: Command line argument: -Dcatalina.base=/ywkj/tomcat Nov 25, 2016 9:14:54 AM org.apache.catalina.startup.VersionLoggerListener log INFO: Command line argument: -Dcatalina.home=/ywkj/tomcat Nov 25, 2016 9:14:54 AM org.apache.catalina.startup.VersionLoggerListener log INFO: Command line argument: -Djava.io.tmpdir=/ywkj/tomcat/temp Nov 25, 2016 9:14:54 AM org.apache.catalina.core.AprLifecycleListener lifecycleEvent INFO: The APR based Apache Tomcat Native library which allows optimal performance in production environments was not found on the java.library.path: /usr/java/packages/lib/amd64:/usr/lib64:/lib64:/lib:/usr/lib Nov 25, 2016 9:14:55 AM org.apache.coyote.AbstractProtocol init INFO: Initializing ProtocolHandler ["http-bio-8080"] Nov 25, 2016 9:14:55 AM org.apache.coyote.AbstractProtocol init INFO: Initializing ProtocolHandler ["ajp-bio-8009"] Nov 25, 2016 9:14:55 AM org.apache.catalina.startup.Catalina load INFO: Initialization processed in 2592 ms Nov 25, 2016 9:14:55 AM org.apache.catalina.core.StandardService startInternal INFO: Starting service Catalina Nov 25, 2016 9:14:55 AM org.apache.catalina.core.StandardEngine startInternal INFO: Starting Servlet Engine: Apache Tomcat/7.0.65 Nov 25, 2016 9:14:55 AM org.apache.catalina.startup.HostConfig deployWAR INFO: Deploying web application archive /ywkj/tomcat/webapps/jenkins.war Nov 25, 2016 9:15:57 AM org.apache.catalina.startup.TldConfig execute INFO: At least one JAR was scanned for TLDs yet contained no TLDs. Enable debug logging for this logger for a complete list of JARs that were scanned but no TLDs were found in them. Skipping unneeded JARs during scanning can improve startup time and JSP compilation time. Jenkins home directory: /root/.jenkins found at: $user.home/.jenkins Nov 25, 2016 9:15:59 AM org.apache.catalina.startup.HostConfig deployWAR INFO: Deployment of web application archive /ywkj/tomcat/webapps/jenkins.war has finished in 64,314 ms Nov 25, 2016 9:15:59 AM org.apache.catalina.startup.HostConfig deployDirectory INFO: Deploying web application directory /ywkj/tomcat/webapps/manager Nov 25, 2016 9:16:00 AM org.apache.catalina.startup.HostConfig deployDirectory INFO: Deployment of web application directory /ywkj/tomcat/webapps/manager has finished in 393 ms Nov 25, 2016 9:16:00 AM org.apache.catalina.startup.HostConfig deployDirectory INFO: Deploying web application directory /ywkj/tomcat/webapps/host-manager Nov 25, 2016 9:16:00 AM org.apache.catalina.startup.HostConfig deployDirectory INFO: Deployment of web application directory /ywkj/tomcat/webapps/host-manager has finished in 557 ms Nov 25, 2016 9:16:00 AM org.apache.catalina.startup.HostConfig deployDirectory INFO: Deploying web application directory /ywkj/tomcat/webapps/docs Nov 25, 2016 9:16:01 AM org.apache.catalina.startup.HostConfig deployDirectory INFO: Deployment of web application directory /ywkj/tomcat/webapps/docs has finished in 310 ms Nov 25, 2016 9:16:01 AM org.apache.catalina.startup.HostConfig deployDirectory INFO: Deploying web application directory /ywkj/tomcat/webapps/examples Nov 25, 2016 9:16:03 AM org.apache.catalina.startup.HostConfig deployDirectory INFO: Deployment of web application directory /ywkj/tomcat/webapps/examples has finished in 2,207 ms Nov 25, 2016 9:16:03 AM org.apache.catalina.startup.HostConfig deployDirectory INFO: Deploying web application directory /ywkj/tomcat/webapps/ROOT Nov 25, 2016 9:16:03 AM org.apache.catalina.startup.HostConfig deployDirectory INFO: Deployment of web application directory /ywkj/tomcat/webapps/ROOT has finished in 283 ms Nov 25, 2016 9:16:03 AM org.apache.coyote.AbstractProtocol start INFO: Starting ProtocolHandler ["http-bio-8080"] Nov 25, 2016 9:16:04 AM org.apache.coyote.AbstractProtocol start INFO: Starting ProtocolHandler ["ajp-bio-8009"] Nov 25, 2016 9:16:04 AM org.apache.catalina.startup.Catalina start INFO: Server startup in 69012 ms Nov 25, 2016 9:16:04 AM jenkins.InitReactorRunner$1 onAttained INFO: Started initialization Nov 25, 2016 9:16:43 AM jenkins.InitReactorRunner$1 onAttained INFO: Listed all plugins Nov 25, 2016 9:16:43 AM jenkins.InitReactorRunner$1 onAttained INFO: Prepared all plugins Nov 25, 2016 9:16:43 AM jenkins.InitReactorRunner$1 onAttained INFO: Started all plugins Nov 25, 2016 9:16:53 AM jenkins.InitReactorRunner$1 onAttained INFO: Augmented all extensions Nov 25, 2016 9:16:53 AM jenkins.InitReactorRunner$1 onAttained INFO: Loaded all jobs Nov 25, 2016 9:17:04 AM hudson.model.AsyncPeriodicWork$1 run INFO: Started Download metadata Nov 25, 2016 9:17:08 AM org.jenkinsci.main.modules.sshd.SSHD start INFO: Started SSHD at port 36605 Nov 25, 2016 9:17:08 AM jenkins.InitReactorRunner$1 onAttained INFO: Completed initialization Nov 25, 2016 9:17:08 AM hudson.WebAppMain$3 run INFO: Jenkins is fully up and running
很迅速的搭建好了一個jenkins