下载Docker Jenkins图片后,在Ubuntu找不到jenkins_home文件夹
我从Docker中央存储库中提取了Docker-Jenkins镜像并运行以下命令
$ docker run -p 8080:8080 -p 50000:50000 Jenkins
在安装过程中,出现下面的几行。
*************************************************************************` Jenkins initial setup is required. An admin user has been created and a password generated. Please use the following password to proceed to installation: xxxxxxxxxxxxxxxxxxxxxx This may also be found at: /var/jenkins_home/secrets/initialAdminPassword *************************************************************************`
但是在我的/var
,不存在jenkins_home
文件夹。
我得到以下错误,我无法访问我的jenkins使用localhost:8080
信息:Jenkins完全正常运行
2016年10月11日上午4时31分19秒winstone.Logger logInternal
信息:JVM正在终止。 closuresWinstone
当生成pipe理员密码时,我可以访问Jenkins仪表板。 但是,立即,JVM正在终止,我不能再访问Jenkins页面。
开始jenkins后,你有两个select:
docker run -p 8080:8080 -d -p 50000:50000 jenkins
( -d
选项是在后台运行容器)你可以进入容器并检查初始的admin密码:check running containers
[root@localhost ~]# docker ps CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES cc73eb6d6f75 jenkins "/bin/tini -- /usr/lo" 32 seconds ago Up 30 seconds 0.0.0.0:8080->8080/tcp, 0.0.0.0:50000->50000/tcp ecstatic_leakey
进入容器
docker exec -it cc73eb6d6f75 bash
并检查adminpasswd的内容
jenkins@cc73eb6d6f75:/$ cat /var/jenkins_home/secrets/initialAdminPassword 1c8be33b31904cacb5xxx
或者你创build你自己的命名的泊坞窗卷:
[root@localhost ~]# docker volume create --name jenkins-volume jenkins-volume
该卷位于/var/lib/docker/volumes/jenkins-volume
主机上。 你可以开始你的jenkins,并连接到音量:
docker run -p 8080:8080 -d -p 50000:50000 -v jenkins-volume:/var/jenkins_home jenkins
您容器内的/var/jenkins_volume
所有数据都将被安装在您指定的卷内。 hostpath是: /var/lib/docker/volumes/jenkins-volume/_data
所以检查我的主机:
[root@localhost ~]# ls /var/lib/docker/volumes/jenkins-volume/_data config.xml hudson.model.UpdateCenter.xml init.groovy.d jobs nodes secret.key updates war copy_reference_file.log hudson.plugins.git.GitTool.xml jenkins.install.InstallUtil.lastExecVersion logs plugins secret.key.not-so-secret userContent workspace credentials.xml identity.key.enc jenkins.install.UpgradeWizard.state nodeMonitors.xml queue.xml.bak secrets users
如果你想安装一个主机目录作为jenkins_home
你需要给jenkins用户(UID 1000)该目录的所有权。
JENKINS_HOME=/home/$(whoami)/jenkins_home mkdir $JENKINS_HOME chown -R 1000 $JENKINS_HOME
运行Jenkins容器:
docker run -d --name jenkins \ -p 8080:8080 -p 50000:50000 \ -v /home/$(whoami)/jenkins_home:/var/jenkins_home \ jenkins
你可以在这里find一个关于如何从一个容器运行Jenkins CI的详细的演练。