17 6 月, 2025

Docker builds Jenkins

1)下去最新jenkins镜像

docker pull registry.cn-shenzhen.aliyuncs.com/xielincai/devops:jenkins_lts

或者去这个地址下载镜像:docker.io/jenkins/jenkins:2.514 – 镜像下载 | docker.io

2)创建jenkens容器

docker run -d -p 8080:8080 -p 50000:50000 -v /home/wy/jenkins:/var/jenkins_home --name jenkins registry.cn-shenzhen.aliyuncs.com/xielincai/devops:jenkins_lts

参数说明:

-p 8080:8080:jenkins 访问端口

-v:将容器的目录挂载到宿主机上

–name:容器名

3)获取初始密码

# 进入容器
docker exec -it jenkins /bin/bash 

# 获取密码
cat /var/lib/jenkins/secrets/initialAdminPassword

4)网页访问jenkins

访问方式:IP地址 + 8080

备注:

部署过程中遇到问题,可联系站长获取帮助,博客首页选择对应的技术支持。Home – STARBUCKET

Docker builds GitLab

1)拉取最新gitlab镜像

docker pull  registry.cn-shenzhen.aliyuncs.com/xielincai/devops:gitlab

2)创建gitlab 容器

docker run -id -p 81:80 -p 9922:22 -v /root/gitlab/etc:/etc/gitlab -v /root/gitlab/log:/var/log/gitlab  -v /root/gitlab/opt:/var/opt/gitlab --restart=always --privileged=true --name gitlab registry.cn-shenzhen.aliyuncs.com/xielincai/devops:gitlab

参数说明:

-p 81:80:80为gitlab的访问端口,映射成宿主机的81

-p 9922:22:22为gitlab的ssh端口,如果用ssh拉取代码就需要这个

-v :将容器里的配置挂载到宿主机上

–restart=always:开机启动

–privileged=true:特权模式,赋予容器几乎与主机相同的权限

–name gitlab:自定义容器名

registry.cn-shenzhen.aliyuncs.com/xielincai/devops:gitlab:启动镜像

3)修改gitlab 配置文件

# 进入容器
docker exec -it gitlab /bin/bash

# 修改gitlab.rb
vi/etc/gitlab/gitlab.rb

# 找到变量改成对应的配置
external_url 'http://ip'

gitlab_rails['gitlab_ssh_host']='ip'

gitlab_rails['gitlab_shell_ssh_port']=9922

# 刷新配置
gitlab-ctlreconfigure

# 修改gitlab.yml
vi/opt/gitlab/embedded/service/gitlab-rails/config/gitlab.yml

gitlab:
    host: ip
    port: 81 # 这里改为81
    https: false

# 重启
gitlab-ctlrestart

# 获取gitlab初始密码
/etc/gitlab/initial_root_password

ubuntu/Centos 软件源

1)ubuntu阿里源

cat > /etc/apt/sources.list << EOF

deb https://mirrors.aliyun.com/ubuntu/ noble main restricted universe multiverse
deb-src https://mirrors.aliyun.com/ubuntu/ noble main restricted universe multiverse

deb https://mirrors.aliyun.com/ubuntu/ noble-security main restricted universe multiverse
deb-src https://mirrors.aliyun.com/ubuntu/ noble-security main restricted universe multiverse

deb https://mirrors.aliyun.com/ubuntu/ noble-updates main restricted universe multiverse
deb-src https://mirrors.aliyun.com/ubuntu/ noble-updates main restricted universe multiverse

# deb https://mirrors.aliyun.com/ubuntu/ noble-proposed main restricted universe multiverse
# deb-src https://mirrors.aliyun.com/ubuntu/ noble-proposed main restricted universe multiverse

deb https://mirrors.aliyun.com/ubuntu/ noble-backports main restricted universe multiverse
deb-src https://mirrors.aliyun.com/ubuntu/ noble-backports main restricted universe multiverse

EOF
sudo apt update

2)Centos阿里源

[base]
name=CentOS-$releasever - Base - mirrors.aliyun.com
baseurl=http://mirrors.aliyun.com/centos/$releasever/os/$basearch/
gpgcheck=1
gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-7

[updates]
name=CentOS-$releasever - Updates - mirrors.aliyun.com
baseurl=http://mirrors.aliyun.com/centos/$releasever/updates/$basearch/
gpgcheck=1
gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-7

[extras]
name=CentOS-$releasever - Extras - mirrors.aliyun.com
baseurl=http://mirrors.aliyun.com/centos/$releasever/extras/$basearch/
gpgcheck=1
gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-7

[centosplus]
name=CentOS-$releasever - Plus - mirrors.aliyun.com
baseurl=http://mirrors.aliyun.com/centos/$releasever/centosplus/$basearch/
gpgcheck=1
enabled=0
gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-7
wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
sudo yum update