jenkins安装

  1. 使用docker-compose安装
    docker-compose.yml:
version: '3'
services:
  jenkins:
    image: 'jenkins/jenkins:lts'
    container_name: jenkins
    restart: always
    ports:
      - '8080:8080'
      - '50000:50000'
    volumes:
      - '/var/jenkins_home:/var/jenkins_home'
  1. 运行前需要分配权限
sudo chown -R /var/jenkins_home

如果按照上面做还是出现Permission denied错误,那么可以检查一下selinux状态,开启的情况下会导致一些服务安装、使用不成功。
查看selinux状态:

[root@localhost ~]# sestatus  
SELinux status:                 enabled  
SELinuxfs mount:                /sys/fs/selinux  
SELinux root directory:         /etc/selinux  
Loaded policy name:             targeted  
Current mode:                   enforcing  
Mode from config file:          enforcing  
Policy MLS status:              enabled  
Policy deny_unknown status:     allowed  
Max kernel policy version:      28
临时关闭,

[root@localhost ~]# setenforce 0
1
永久关闭,可以修改配置文件/etc/selinux/config,将其中SELINUX设置为disabled,如下,

[root@localhost ~]# cat /etc/selinux/config   

# This file controls the state of SELinux on the system.  
# SELINUX= can take one of these three values:  
#     enforcing - SELinux security policy is enforced.  
#     permissive - SELinux prints warnings instead of enforcing.  
#     disabled - No SELinux policy is loaded.  
#SELINUX=enforcing  
SELINUX=disabled  
# SELINUXTYPE= can take one of three two values:  
#     targeted - Targeted processes are protected,  
#     minimum - Modification of targeted policy. Only selected processes are protected.   
#     mls - Multi Level Security protection.  
SELINUXTYPE=targeted

[root@rdo ~]# sestatus  
SELinux status:                 disabled
  1. docker-compose up -d启动jenkins,访问Jenkins网址[http://[server_ip]:8080]
    This may also be found at: /var/jenkins_home/secrets/initialAdminPassword在这里可以发现初始密码
  2. jenkins容器是无法识别容器外的git,maven,jdk的
  • 直接把他们的宿主机上的安装位置挂载给容器,使其能访问
  • 如果外部没装,jenkins自带了git和jdk,docker exec -it 容器id /bin/bash
    进入容器,echo $JAVA_HOME找到java路径,which git 找到git路径,jenkins 容器中一般没有 maven 提供的,所以 jenkins 配置中我使用 install automatically

你可能感兴趣的:(jenkins安装)