docker方式启动Jenkins

docker方式启动Jenkins

1.启动命令

我已经打包好了文件,如下命令即可启动

复制代码
docker run -d -v jenkins_home:/var/jenkins_home -p 8088:8080 -p 50000:50000 --restart=on-failure registry.cn-hangzhou.aliyuncs.com/devops_de/jenkins:lts-jdk17

还需要设置一下目录权限,要不然Jenkins用户无法写入

复制代码
sudo chmod -R 777 /path/to/host/dir

1.1 docker-compose 方式启动

docker-compose.yaml文件如下

复制代码
services:
  jenkins:
    image: registry.cn-hangzhou.aliyuncs.com/devops_de/jenkins:lts-jdk17
    ports:
      - "8088:8080"
    volumes:
      - jenkins_home:/var/jenkins_home
  ssh-agent:
    image: registry.cn-hangzhou.aliyuncs.com/devops_de/ssh-agent:latest
volumes:
  jenkins_home:

注:未设置目录权限报错如下

复制代码
​
[root@centos-1 ~]# docker logs -f f691a152dc6c
touch: cannot touch '/var/jenkins_home/copy_reference_file.log': Permission denied
Can not write to /var/jenkins_home/copy_reference_file.log. Wrong volume permissions?
touch: cannot touch '/var/jenkins_home/copy_reference_file.log': Permission denied
Can not write to /var/jenkins_home/copy_reference_file.log. Wrong volume permissions?
touch: cannot touch '/var/jenkins_home/copy_reference_file.log': Permission denied
Can not write to /var/jenkins_home/copy_reference_file.log. Wrong volume permissions?
touch: cannot touch '/var/jenkins_home/copy_reference_file.log': Permission denied
Can not write to /var/jenkins_home/copy_reference_file.log. Wrong volume permissions?
touch: cannot touch '/var/jenkins_home/copy_reference_file.log': Permission denied
Can not write to /var/jenkins_home/copy_reference_file.log. Wrong volume permissions?
touch: cannot touch '/var/jenkins_home/copy_reference_file.log': Permission denied
Can not write to /var/jenkins_home/copy_reference_file.log. Wrong volume permissions?
touch: cannot touch '/var/jenkins_home/copy_reference_file.log': Permission denied
Can not write to /var/jenkins_home/copy_reference_file.log. Wrong volume permissions?
touch: cannot touch '/var/jenkins_home/copy_reference_file.log': Permission denied
Can not write to /var/jenkins_home/copy_reference_file.log. Wrong volume permissions?

访问本地的8088端口

复制代码
192.168.0.101:8088

2.查看密码

复制代码
[root@centos-1 ~]# cat /data/jenkins_home/secrets/initialAdminPassword
b2543e8775344c4db4180e2bdfe39a68

3.登录查看

http://192.168.0.101:8089/

相关推荐
java_logo1 小时前
Docker 部署填鸭表单完整教程:搭建私有化问卷与表单收集平台
docker·表单·问卷·tduck·轩辕镜像·填鸭表单·tduck platform
玉&心1 小时前
K8s HPA自动扩缩容
docker·云原生·容器·hpa·kubernates
小小ken1 小时前
docker容器(数据)备份及恢复:使用docker-volume-backup项目
docker·容器
wdfk_prog1 小时前
ROS教程06:ROS1 Node 启动与停止流程
运维·缓存·docker·容器·ros
阿虎儿1 小时前
2025 年的自托管(Self-Hosting)
docker·容器
叶总没有会2 小时前
Docker 基础+实战
运维·docker·云原生·容器
j7~3 小时前
【C++微服务项目开发脚手架】(环境篇)虚拟机 + Docker + MySQL/Redis/RabbitMQ/ES/etcd/FastDFS 全套配齐
linux·c++·ubuntu·docker·vmware·项目开发·微服务脚手架
天天喝旺仔3 小时前
Go 泛型实战:从类型参数、约束到可复用泛型容器与函数
数据结构·算法·容器·go
小马同学-3 小时前
docker容器
docker·容器
DarkAthena3 小时前
拒绝Docker Desktop-在win11上运行docker容器的替代方案
docker