docker从0安装Jenkins
Ubuntu初始化
sudo apt-get install openssh-server
sudo vim /etc/ssh/sshd_config
设置静态IP
cd /etc/netplan
···
network:
version: 2
renderer: NetworkManager
ethernets:
ens33: # 网卡名称
dhcp4: no # 关闭dhcp
dhcp6: no
addresses: [192.168.0.108/24] # 静态ip
gateway4: 192.168.0.1 # 网关
nameservers:
addresses: [8.8.8.8, 114.114.114.114] #dns
···
sudo netplan apply
docker安装
sudo apt-get update
sudo apt-get install \
apt-transport-https \
ca-certificates \
curl \
gnupg \
lsb-release
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg
echo \
"deb [arch=amd64 signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://download.docker.com/linux/ubuntu \
$(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
sudo apt-get update
sudo apt-get install docker-ce docker-ce-cli containerd.io -y
#切换镜像源
sudo vim /etc/docker/daemon.json
···
{
"registry-mirrors": ["https://docker.mirrors.ustc.edu.cn"]
}
···
sudo systemctl restart docker
#Docker中国官方镜像源
https://registry.docker-cn.com
#网易镜像源
http://hub-mirror.c.163.com
#中国科技大学镜像源
https://docker.mirrors.ustc.edu.cn
安装jdk
#第一步:上传或下载安装包
cd /usr/local
jdk-8u152-linux-x64.tar.gz
#第二步:解压安装包
tar -zxvf jdk-8u152-linux-x64.tar.gz
#第三步:建立软连接
ln -s /usr/local/jdk1.8.0_152/ /usr/local/jdk
#第四步:修改环境变量
vim /etc/profile
export JAVA_HOME=/usr/local/jdk
export JRE_HOME=$JAVA_HOME/jre
export CLASSPATH=.:$CLASSPATH:$JAVA_HOME/lib:$JRE_HOME/lib
export PATH=$PATH:$JAVA_HOME/bin:$JRE_HOME/bin
#通过命令source /etc/profile让profile文件立即生效
source /etc/profile
安装maven
#第一步:上传或下载安装包
cd /usr/local
apache-maven-3.6.1-bin.tar.gz
#第二步:解压安装包
tar -zxvf apache-maven-3.6.1-bin.tar.gz
#第三步:建立软连接
ln -s /usr/local/apache-maven-3.6.1/ /usr/local/maven
#第四步:修改环境变量
vim /etc/profile
export MAVEN_HOME=/usr/local/maven
export PATH=$PATH:$MAVEN_HOME/bin
#通过命令source /etc/profile让profile文件立即生效
source /etc/profile
jenkins安装
docker pull jenkins/jenkins:lts
mkdir /docker
mkdir /docker/jenkins_home
chown -R 1000 /docker/jenkins_home/
#root该用户为启动Jenkins时的所属用户,y
sudo usermod -aG docker root
sudo docker restart jenkins
sudo chmod 666 /var/run/docker.sock
docker run -di --name=jenkins -p 8080:8080 -p 9000:9000 -v /docker/jenkins_home/:/var/jenkins_home -v /usr/local/jdk:/usr/local/jdk -v /usr/local/maven:/usr/local/maven -v /var/run/docker.sock:/var/run/docker.sock -v $(which docker):/usr/bin/docker jenkins/jenkins:lts
cd /docker/jenkins_home/updates/
sed -i 's/http:\/\/updates.jenkins-ci.org\/download/https:\/\/mirrors.tuna.tsinghua.edu.cn\/jenkins/g' default.json && sed -i 's/http:\/\/www.google.com/https:\/\/www.baidu.com/g' default.json
标签:local,sudo,etc,usr,jenkins,Jenkins,docker,安装
From: https://www.cnblogs.com/lbao/p/17909281.html