Docker Compose部署jenkins

Docker Compose部署jenkins

Docker Compose部署jenkins

登录服务器并创建jenkins所需要的目录

mkdir jenkins

cd jenkins

touch docker-compose.yaml

mkdir data

配置文件

docker-compose.yml配置文件

jenkins:
        image: jenkins/jenkins:lts
        volumes:
            - ./data/jenkins/:/var/jenkins_home
            - /var/run/docker.sock:/var/run/docker.sock
            - /usr/bin/docker:/usr/bin/docker
            - ./usr/lib/x86_64-linux-gnu/libltdl.so.7:/usr/lib/x86_64-linux-gnu/libltdl.so.7
        ports:
            - "2027:8080"
        expose:
            - "8080"
            - "50000"
        privileged: true
        user: root
        restart: always
        container_name: jenkins
        environment:
            JAVA_OPTS: '-Djava.util.logging.config.file=/var/jenkins_home/log.properties'

启动jenkins

docker-compose up -d  # 启动
docker-compose stop  # 停止
docker-compose start # 启动
docker-compose restart # 重启
docker-compose down # 停止容器并移除

权限问题

jenkins启动成功后日志会出现报错那是因为权限问题导致的我们需要给data目录权限

chown -R 1000:1000 /data/jenkins

解决完之后我们访问jenkins服务器IP+端口访问
image.png

解锁jenkins密钥如下命令会输出密钥复制到jenkins并点击继续即可

cat /data/jenkins/secrets/initialAdminPassword

如果上面的查看密钥方法没找到的话可以进入容器内查看

docker exec -it jenkins bash 

cat /var/jenkins_home/secrets/initialAdminPassword

往后就是基础操作了下一步进行插件安装然后再创建用户即可

评论

  欢迎来访晴天のVlog,博主无话可说,没有发布任何公告!

  欢迎来访晴天のVlog,评论区暂空,等你抢C位。

Your browser is out-of-date!

Update your browser to view this website correctly. Update my browser now

×