centos环境用docker安装jenkins相关命令

1,查询安装包
yum list installed | grep docker
2, 卸载
yum -y remove docker.x86_64 docker-client.x86_64 docker-common.x86_64
3,删除存在镜像和容器
rm -rf /var/lib/docker
4,安装docker
yum install docker-ce -y
5, 启动docker
systemctl restart docker
6,创建软链接
systemctl enable docker
7,清除docker缓存命令
docker system prune -a
8, 编辑配置文件
vim /etc/docker/daemon.json
9,停止容器
docker stop jenkins
10, 删除容器
docker rm -f
11,删除镜像
docker rmi docker.io/jenkins
###############################################
1,安装jenkins
docker pull jenkins/jenkins:lts
挂载
mkdir -p /var/lib/jenkins
chmod -R 777 /var/lib/jenkins
2,运行jenkins
docker run
–name jenkins
-p 9000:8080
-p 50000:50000
-v /var/lib/jenkins:/var/jenkins_home
-d jenkins/jenkins:lts
3,启动容器,查看jenkins初始密码
docker exec -it jenkins cat /var/jenkins_home/secrets/initialAdminPassword
或者通过日志查看docker logs jenkins
或者通过挂载目录查看
cat /var/lib/jenkins/secrets/initialAdminPassword
4,参考文章
https://blog.csdn.net/brianzb/article/details/126885057
5,sed字符串替换
sed -i ‘s#https://updates.jenkins.io/update-center.json#https://mirrors.cloud.tencent.com/jenkins/updates/update-center.json#g’ hudson.model.UpdateCenter.xml
################################################################
1, wgeT命令
yum install wget -y
2,安装jdk17
cd /usr/local
wget https://download.oracle.com/java/17/latest/jdk-17_linux-x64_bin.tar.gz
或者手动下载:scp jdk-17_linux-x64_bin.tar.gz [email protected]:/usr/local/
tar -zxvf jdk-17_linux-x64_bin.tar.gz
mv jdk-17 java
配置环境变量:
vim /etc/profile 如下
export JAVA_HOME=/usr/local/java
export PATH= P A T H : PATH: PATH:JAVA_HOME/bin
export CLASSPATH=.: J A V A H O M E / l i b / d t . j a r : JAVA_HOME/lib/dt.jar: JAVAHOME/lib/dt.jar:JAVA_HOME/lib/tools.jar
生效:
source /etc/profile
3,阿里云镜像(配置 Maven setting.xml)

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

查看Java地址ls -lrt /etc/alternatives/java
4,Maven配置
vim /etc/profile

export M2_HOME=/usr/bin/maven/apache-maven-3.6.3
PATH=$M2_HOME/bin:$PATH

5, 安装git
yum install git
6,

pipeline {
    agent any

    stages {
        stage('Build and Run Docker Containers') {
            steps {
                script {
                    def dockerCommand = """
                        docker-compose up -d
                    """
                    sh dockerCommand
                }
            }
        }
    }

    post {
        always {
            stage('Clean Up') {
                steps {
                    script {
                        def dockerCommand = """
                            docker-compose down
                        """
                        sh dockerCommand
                    }
                }
            }
        }
    }
}

你可能感兴趣的:(centos,docker,jenkins)