Docker:Dockerfile-构建jekins镜像

Docker:Dockerfile-构建jekins镜像

  • Dockerfile

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    FROM centos:7 

    # author info
    MAINTAINER zyf

    # install wget to download files
    RUN yum install wget -y

    # install git
    RUN yum install git -y

    RUN mkdir /robotservice2.0 /robotservice2.0/lib

    RUN cd /opt

    # download jdk
    RUN wget -P /opt --no-check-certificate --no-cookies --header "Cookie: oraclelicense=accept-securebackup-cookie" http://download.oracle.com/otn-pub/java/jdk/8u131-b11/d54c1d3a095b4ff2b6607d096fa80163/jdk-8u131-linux-x64.tar.gz

    # download maven
    RUN wget -P /opt http://mirror.bit.edu.cn/apache/maven/maven-3/3.5.4/binaries/apache-maven-3.5.4-bin.tar.gz

    # download tomcat
    RUN wget -P /opt http://mirror.bit.edu.cn/apache/tomcat/tomcat-8/v8.5.40/bin/apache-tomcat-8.5.40.tar.gz

    # unzip jdk
    RUN tar -xvf /opt/jdk-8u131-linux-x64.tar.gz -C /opt/

    # unzip maven
    RUN tar -xvf /opt/apache-maven-3.5.4-bin.tar.gz -C /opt/

    # unzip tomcat
    RUN tar -xvf /opt/apache-tomcat-8.5.40.tar.gz -C /opt

    # set environment
    ENV JAVA_HOME /opt/jdk1.8.0_131
    ENV MAVEN_HOME /opt/apache-maven-3.5.4
    ENV CLASSPATH .:$JAVA_HOME/jre/lib/rt.jar:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar
    ENV PATH $JAVA_HOME/bin:$MAVEN_HOME/bin:$PATH
    ENV JAVA_TOOL_OPTIONS -Dfile.encoding=UTF8

    # download jenkins
    RUN wget -P /opt/apache-tomcat-8.5.40/webapps https://mirrors.tuna.tsinghua.edu.cn/jenkins/war-stable/2.164.2/jenkins.war

    # startup tomcat
    CMD /opt/apache-tomcat-8.5.40/bin/catalina.sh run

    # expose memcached port
    EXPOSE 8080
  • 编译Dockerfile
    docker build -t jenkins:1.0.0 .

  • 运行容器
    docker run –name jenkins -p 9090:8080 -p 50000:50000 -v /var/run/docker.sock:/var/run/docker.sock -v $(which docker):/bin/docker -v /var/jenkins_home:/var/jenkins_home -d jenkins:1.0.0

  • 访问
    http://**:9090/jenkins

  • 进入容器
    docker exec -it containerId /bin/bash

  • 查看jenkins密码
    cat /root/.jenkins/secrets/initialAdminPassword


人生两苦:想要却不得,拥有却失去。 –褚禄山
珍惜当下,与君共勉~


本文标题:Docker:Dockerfile-构建jekins镜像

文章作者:fufua

发布时间:2019年04月13日 - 10:54:13

最后更新:2019年05月09日 - 14:04:56

原始链接:https://qq1028951741.github.io/2019/04/13/Docker:Dockerfile-构建jekins镜像/

许可协议: 署名-非商业性使用-禁止演绎 4.0 国际 转载请保留原文链接及作者。

this is end, thank you for reading