過年找點樂子,用 Docker 把一些工作上常見的服務都架設一次好了 XD 整體工作上仍主要都還是 ansible 管理數百台機器,近期有同事對 docker 很感興趣,我就努力推坑,推坑前也得親自走一下是吧 :P
連續動作:
% cat docker-compose.yml# https://docs.docker.com/compose/compose-file/compose-versioning/version: '3.8'services:jenkins:# https://hub.docker.com/_/jenkinsimage: jenkins/jenkins:lts# https://docs.docker.com/config/containers/start-containers-automatically/#use-a-restart-policyrestart: unless-stoppedprivileged: trueuser: rootports:# HOST:CONTAINER- 8080:8080container_name: jenkinsvolumes:- ~/docker_jenkins_home:/var/jenkins_home% docker-compose up[+] Running 1/0✔ Container jenkins Created 0.0sAttaching to jenkinsjenkins | Running from: /usr/share/jenkins/jenkins.warjenkins | webroot: /var/jenkins_home/war...jenkins | *************************************************************jenkins | *************************************************************jenkins | *************************************************************jenkins |jenkins | Jenkins initial setup is required. An admin user has been created and a password generated.jenkins | Please use the following password to proceed to installation:jenkins |jenkins | 54b6458ba37b4178bdc77f7d9eccbd0fjenkins |jenkins | This may also be found at: /var/jenkins_home/secrets/initialAdminPasswordjenkins |jenkins | *************************************************************jenkins | *************************************************************jenkins | *************************************************************
這時就可以到 http://localhost:8080 繼續走完 jenkins 的架設,包括也看到的啟動碼,當然,也可以搞剛用 docker exec 指令來列出:
% docker exec jenkins cat /var/jenkins_home/secrets/initialAdminPassword54b6458ba37b4178bdc77f7d9eccbd0f
除此之外,在本機 ~/docker_jenkins_home 也可以看到相關結構:
% tree -L 1 ~/docker_jenkins_home/Users/user/docker_jenkins_home├── config.xml├── copy_reference_file.log├── hudson.model.UpdateCenter.xml├── jenkins.telemetry.Correlator.xml├── jobs├── nodeMonitors.xml├── nodes├── plugins├── secret.key├── secret.key.not-so-secret├── secrets├── updates├── userContent├── users└── war9 directories, 7 files
只是剩下的就靠 http://localhost:8080 走安裝流程,收工
而原先跑 docker-compose up 的那個環境可以用 ctrl+c 來停掉,未來可以靠 docker-compose up -d 來重新啟動
^CGracefully stopping... (press Ctrl+C again to force)[+] Stopping 1/1✔ Container jenkins Stopped 0.2scanceled
沒有留言:
張貼留言