使用docker安装jenkins
1、安装环境
root@ruide-server:~# lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu 24.10
Release: 24.10
Codename: oracular
2、安装docker-ce
docker安装教程网上很多,不做赘述
root@ruide-server:~# docker version
Client: Docker Engine - CommunityVersion: 27.3.1API version: 1.47Go version: go1.22.7Git commit: ce12230Built: Fri Sep 20 11:41:03 2024OS/Arch: linux/amd64Context: defaultServer: Docker Engine - CommunityEngine:Version: 27.3.1API version: 1.47 (minimum version 1.24)Go version: go1.22.7Git commit: 41ca978Built: Fri Sep 20 11:41:03 2024OS/Arch: linux/amd64Experimental: falsecontainerd:Version: 1.7.24GitCommit: 88bf19b2105c8b17560993bee28a01ddc2f97182runc:Version: 1.2.2GitCommit: v1.2.2-0-g7cb3632docker-init:Version: 0.19.0GitCommit: de40ad0
3、安装jenkins
3.1 安装jenkins:lts-jdk17
docker run -d -p 8099:8080 -p 50000:50000 -v jenkins-data:/var/jenkins_home --name myjenkins
--restart always jenkins/jenkins:lts-jdk17
3.2 访问
http://127.0.0.1:8099/
docker 日志中获取密码,粘贴至上图输入框,点继续
安装插件,推荐的即可
FAQ
1 jenkins执行mvn命令报内存不足错误
[Pipeline] sh
+ mvn -B -DskipTests clean package
library initialization failed - unable to allocate file descriptor table - out of memoryAborted (core dumped)
[Pipeline] }
原因:docker启动容器时,若未给容器配置ulimit,则从docker守护进程上设置的默认ulimits继承,这个值太大?会报这个错
ulimit nofile这个值太大报错的原因:
JDK8启动程序时会尝试为文件句柄分配内存,文件句柄数即系统设置ulimit nofile的值,若ulimit nofile很大,文件句柄数量十分巨大,就导致了即便分配10G运存还是Out Of Memory。旧版的Linux默认句柄数为1024,则不会出现该异常。
参考链接:docker 报错 library initialization failed - unable to allocate file descriptor table - out of memory