Docker运行Jnekins

下载镜像

docker pull jenkins/jenkins:2.419

赋予权限

chown -R 1000:1000 /opt/workspace/
chown -R 1000:1000 /usr/local/maven
chown -R 1000:1000 /usr/local/git
chown -R 1000:1000 /usr/local/jdk11/jdk-11.0.20
chown -R 1000:1000 /opt/jenkins
chown -R 1000:1000 /etc/localtime

启动容器

#启动命令:
# 容器后台运行 -d
# root身份运行 -u root
# 网络指定host --net=host,可通过主机网址访问容器内服务
# 端口映射为8088:8080
# 工作目录挂载为 -v
docker run -u root -d \
-p 8088:8080 \
-v /opt/jenkins/jenkins_home:/var/jenkins_home \
-v /opt/workspace/:/var/jenkins_home/workspace/ \
-v /var/run/docker.sock:/var/run/docker.sock \
-v /usr/bin/docker:/usr/bin/docker \
-v /usr/local/jdk11/jdk-11.0.20:/usr/local/jdk11/jdk-11.0.20 \
-v /usr/local/maven:/usr/local/maven \
-v /usr/local/git:/usr/local/git
-e JAVA_OPTS="-Dorg.apache.commons.jelly.tags.fmt.timeZone='Asia/Shanghai" \
--name myjenkins jenkins/jenkins:2.419

查看密码

# 查看容器
docker ps
# 进入容器
docker exec -it myjenkins /bin/bash
# 查看密码
cat /root/.jenkins/secrets/initialAdminPassword

更换站点

https://mirrors.huaweicloud.com/jenkins/updates/update-center.json
posted @ 2024-01-18 15:31  leepandar  阅读(3)  评论(0编辑  收藏  举报