在docker容器安装Jenkins

  1. 环境准备
    • docker
    • Linux

2.步骤

  • 在docker安装jenkins
➜  ~ docker pull jenkins
Using default tag: latest
latest: Pulling from library/jenkins
c73ab1c6897b: Pull complete 
1ab373b3deae: Pull complete 
b542772b4177: Pull complete 
57c8de432dbe: Pull complete 
da44f64ae999: Pull complete 
0bbc7b377a91: Pull complete 
Digest: sha256:93263adb6ab1ecb240b342a9e62e782c5b46d4d87cd01830021d1dfe89acb518
Status: Downloaded newer image for jenkins:latest
➜  ~ 
➜  ~ 
➜  ~ docker images
REPOSITORY                   TAG                 IMAGE ID            CREATED             SIZE
jenkins                      latest              7b210b6c238a        15 hours ago        801MB
  • 建立jenkins储存目录
➜  data mkdir jenkins
➜  data cd jenkins 
➜  jenkins pwd
/home/deepin/soft/data/jenkins
  • 运行jenkins镜像
    • -p 参数指定8008转发到容器内部的8080端口
    • -v参数将容器外的jenkins目录,挂在到容器内的jenkins_home目录
➜  data docker run -p 8008:8080 -v /home/deepin/soft/data/jenkins:/var/jenkins_home --name jenkins_c -d jenkins 
60cc22760faefffd6aa98e55938d15e48a2063cc0878c7653eed43cbb5ab71a7
➜  data 
  • 查看jenkins初始密码
    • jenkins启动时会将初始密码打印出来,同时也是会写到一个文件
    • 查看jenkins启动日志
docker logs $(docker ps -f name=jenkins_c -q)
...
...
    INFO: 

*************************************************************
*************************************************************
*************************************************************

Jenkins initial setup is required. An admin user has been created and a password generated.
Please use the following password to proceed to installation:

bdda710223384081aff3fe2156574e69

This may also be found at: /var/jenkins_home/secrets/initialAdminPassword

*************************************************************
*************************************************************
*************************************************************
  • 配置jenkins
    • 输入口令进入jenkins之后,有两个选择,选择推荐的插件安装即可。(需要联网安装)
    • 安装插件之后设置用户名密码,设置成功后即可使用。

你可能感兴趣的:(在docker容器安装Jenkins)