创建Jenkins容器(使用volume)
docker create --name jenkins -uroot -p 8080:8080 --privileged=true -v jenkins-data:/var/jenkins_home -v /home/jenkins:/home -v /var/run/docker.sock:/var/run/docker.sock docker.io/jenkinsci/blueocean
docker volume: jenkins‐data
创建Jenkins容器(使用宿主机路径)
docker create --name jenkins -uroot -p 8080:8080 --privileged=true -v /home/jenkins-data:/var/jenkins_home -v /home/jenkins:/home -v /var/run/docker.sock:/var/run/docker.sock docker.io/jenkinsci/blueocean
创建Jenkins容器(使用https_proxy代理)
docker run -d --name jenkins -e HTTP_PROXY=http://192.168.20.2:1087 -e HTTPS_PROXY=http://192.168.20.2:1087 -e NO_PROXY=127.0.0.1,LOCALHOST,192.168.20.0/24 -u root -p 8080:8080 --privileged=true -v /home/jenkins-data:/var/jenkins_home -v /home/jenkins:/home -v /var/run/docker.sock:/var/run/docker.sock docker.io/jenkinsci/blueocean
使用jenkins/jenkins镜像
使用
docker.io/jenkinsci/blueocean
镜像会导致插件无法完整下载下来。
配置挂载目录权限,不然会报权限问题:
chmod 777 -R /home/jenkins-data
容器启动:
docker run -d --name jenkins -p 8080:8080 --privileged=true -v /home/jenkins-data:/var/jenkins_home -v /var/run/docker.sock:/var/run/docker.sock jenkins/jenkins
启动Jenkins容器
docker start jenkins
访问jenkins
查看密码
cat /home/jenkins-data/secrets/initialAdminPassword
配置插件下载清华源
sed -i 's/https:\/\/updates.jenkins.io\/download/https:\/\/mirrors.tuna.tsinghua.edu.cn\/jenkins/g' default.json && sed -i 's/https:\/\/www.google.com/https:\/\/www.baidu.com/g' default.json
插件-高级选项中配置清华源:
https://mirrors.tuna.tsinghua.edu.cn/jenkins/updates/update-center.json