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/

相关推荐
潘正翔1 天前
docker核心概念
linux·运维·服务器·docker·容器·centos·运维开发
Java小白笔记1 天前
Docker 安装配置完全指南:MacOS 、Windows、Linux环境下的安装、配置与验证
linux·macos·docker
copyer_xyf1 天前
Docker 入门与实战:容器化 React + NestJS 项目
docker
刘马想放假2 天前
Docker 从入门到进阶:一篇写给工程师的系统化实战指南
运维·docker·容器
Wang's Blog2 天前
Go-Zero进阶实战2: 使用 Docker Compose 编排与部署微服务
docker·微服务·golang
zjun30212 天前
如何搭建TRAE IDE 连接到容器开发环境
docker·容器·ascend·trae
寒冰碧海2 天前
大模型部署从0到1(一):通用环境全流程准备|NVIDIA驱动+Docker+NVIDIA Container Toolkit
运维·docker·容器
hj2862512 天前
K8S 核心组件与资源概念 + 带注释命令 + 实操案例版笔记
笔记·容器·kubernetes
nece0012 天前
Kubernetes v1.36.0 + Ubuntu24.04 + containerd 2.x WordPress 完整部署文档
云原生·容器·kubernetes
hdsoft_huge2 天前
SpringBoot 系列 20:Jar 打包 + Docker 容器化 + Compose 一键部署|服务器上线 & 零停机平滑升级全教程
spring boot·docker·jar