• 安装和启动docker


    1、安装和启动docker

    yum update -y

    yum install -y yum-utils

    yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo

    yum -y install docker-ce

    systemctl start docker

    2、设置镜像

    vi /etc/docker/daemon.json

    {
    "registry-mirrors": ["https://aj2rgad5.mirror.aliyuncs.com"]
    }

    3、开放管理端口映射

    vi /lib/systemd/system/docker.service

    将第11行的ExecStart=/usr/bin/dockerd,替换为:

    ExecStart=/usr/bin/dockerd -H tcp://0.0.0.0:2375 -H unix:///var/run/docker.sock -H tcp://0.0.0.0:7654

    2375是管理端口,7654是备用端口

    在~/.bashrc中写入docker管理端口

    export DOCKER_HOST=tcp://0.0.0.0:2375

    source ~/.bashrc

    4、重启docker

    systemctl daemon-reload && service docker restart

    5、测试docker是否正常安装和运行

    docker run hello-world

    Hello from Docker!
    This message shows that your installation appears to be working correctly.


    1、安装maven

    wget http://mirror.bit.edu.cn/apache/maven/maven-3/3.5.0/binaries/apache-maven-3.5.0-bin.tar.gz

    tar -zxvf apache-maven-3.5.0-bin.tar.gz

    vi ~/.bashrc

    export MAVEN_HOME=/usr/local/apache-maven-3.5.0
    export PATH=$PATH:$MAVEN_HOME/bin

    source ~/.bashrc

    mvn -version

    cd /usr/local/apache-maven-3.5.0/conf

    vi settings.xml

    <mirror>
    <id>nexus-aliyun</id>
    <mirrorOf>*</mirrorOf>
    <name>Nexus aliyun</name>
    <url>http://maven.aliyun.com/nexus/content/groups/public</url>
    </mirror>

    2、安装git

    yum install -y git

    git --version

    3、将代码推送到github中

    1、新建一个任务

    2、构建一个自由风格的软件项目

    3、配置Github,包括github地址,用户名和密码,分支

    4、配置构建环境

    增加构建步骤 -> invoker top-level-Maven targets

    Maven version: maven3.5.0
    Goals: clean package
    POM: pom.xml

    5、增加构建步骤 -> execute shell

    #!/bin/bash
    REGISTRY_URL=192.168.189.54:2375
    WORK_DIR=/root/work_build
    PROJECT_NAME=eureka-server
    PROJECT_VERSION=0.0.1-SNAPSHOT
    if [ ! -e ${WORK_DIR}/${PROJECT_NAME} ] && [ ! -d ${WORK_DIR}/${PROJECT_NAME} ]; then
    mkdir -p ${WORK_DIR}/${PROJECT_NAME}
    echo "Create Dir: ${WORK_DIR}/${PROJECT_NAME}"
    fi
    if [ -e ${WORK_DIR}/${PROJECT_NAME}/Dockerfile ]; then
    rm -rf ${WORK_DIR}/${PROJECT_NAME}/Dockerfile
    echo "Remove File: ${WORK_DIR}/${PROJECT_NAME}/Dockerfile"
    fi
    cp /root/.jenkins/workspace/eureka-server/Dockerfile ${WORK_DIR}/${PROJECT_NAME}/
    cp /root/.jenkins/workspace/eureka-server/target/*.jar ${WORK_DIR}/${PROJECT_NAME}/
    cd ${WORK_DIR}/${PROJECT_NAME}/
    docker build -t ${REGISTRY_URL}/eshop-detail/${PROJECT_NAME}:${PROJECT_VERSION} .
    docker push ${REGISTRY_URL}/eshop-detail/${PROJECT_NAME}:${PROJECT_VERSION}
    if docker ps -a | grep ${PROJECT_NAME}; then
    docker rm -f ${PROJECT_NAME}
    echo "Remove Docker Container: ${PROJECT_NAME}"
    fi
    docker run -d -p 8761:8761 --name ${PROJECT_NAME} ${REGISTRY_URL}/eshop-detail/${PROJECT_NAME}:${PROJECT_VERSION}

    6、执行一些修改

    (1)修改1:在系统配置中设置maven,然后在配置中选择自己配置的maven版本,解决cannot run mvn program的错误

    (2)修改2:编写DockerFile

    FROM frolvlad/alpine-oraclejdk8:slim
    VOLUME /tmp
    ADD eureka-server-0.0.1-SNAPSHOT.jar app.jar
    #RUN bash -c 'touch /app.jar'
    ENTRYPOINT ["java","-Djava.security.egd=file:/dev/./urandom","-jar","/app.jar"]
    EXPOSE 8761

    7、执行构建

    8、访问http://192.168.31.253:8761/,可以看到eureka-server的页面

  • 相关阅读:
    ASP输出成n列的表格形式显示的方法,多行多列
    1003
    1005
    Linq to sql 迭代器bug?
    通过global.asax向所有文件注册js
    asp.net任务调度之Quartz.net
    SQL Server 批量插入数据的两种方法
    C#通过反射实例化对象
    linq to sql 学习
    C#全角和半角转换
  • 原文地址:https://www.cnblogs.com/sunliyuan/p/11779743.html
Copyright © 2020-2023  润新知