記事ディレクトリ
1. 目標
Docker環境にJenkinsをインストールし、パイプラインの事前学習を実施します。
2. 前提条件
- 港湾労働者
- Linux
3. 具体的な手順
3.1 イメージのプル
➜ ~ docker pull jenkins/jenkins
Using default tag: latest
latest: Pulling from jenkins/jenkins
0e29546d541c: Pull complete
a881d3e39b57: Pull complete
d424caad5b90: Pull complete
469ee726cc8f: Pull complete
f5eff683d188: Pull complete
955c78102a93: Pull complete
1e670fe34dae: Pull complete
30a5b207ad53: Pull complete
3c421004e233: Pull complete
e2729810a28a: Pull complete
4c14906574b5: Pull complete
8d6f1717fa64: Pull complete
a43947c0b965: Pull complete
0dfe4ad317f0: Pull complete
51f8f56f3e20: Pull complete
3944cb7b63c3: Pull complete
f3ebba26875d: Pull complete
Digest: sha256:0c31a58707a69449d2db06a31dc76b6bdf7f690d2664406104185eac27d0d54b
Status: Downloaded newer image for jenkins/jenkins:latest
docker.io/jenkins/jenkins:latest
➜ ~ docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
jenkins/jenkins latest 1c520775844c 45 hours ago 442MB
3.2巻
mkdir -p /var/jenkins_mount
chmod 777 /var/jenkins_mount
3.3 Jenkins コンテナの作成と起動
- -d はイメージをバックグラウンドで実行します
- -p 10240:8080 は、ミラーの 8080 ポートをサーバーの 10240 ポートにマップします。
- -p 10241:50000 は、ミラーの 50000 ポートをサーバーの 10241 ポートにマップします。
- -v /var/jenkins_mount:/var/jenkins_mount /var/jenkins_home ディレクトリは、コンテナー jenkins の作業ディレクトリです。更新後に元の作業ディレクトリを容易に使用できるように、ハードディスク上のディレクトリをこの場所にマウントします。画像。ここで設定するのは、上で作成した /var/jenkins_mount ディレクトリです。
- -v /etc/localtime:/etc/localtime は、コンテナーにサーバーと同じ時刻設定を使用するように指示します。
- –name myjenkins コンテナーにエイリアスを与えます
➜ ~ docker run -d -p 10240:8080 -p 10241:50000 -v /var/jenkins_mount:/var/jenkins_home -v /etc/localtime:/etc/localtime --name myjenkins jenkins/jenkins
e62f855f38a8b801880a2deaa7ffb00ec80aa5eb2787ae613288a6f609285acd
➜ ~ docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
e62f855f38a8 jenkins/jenkins "/sbin/tini -- /usr/…" 16 seconds ago Up 15 seconds 0.0.0.0:10240->8080/tcp, 0.0.0.0:10241->50000/tcp myjenkins
3.4 ログの表示
➜ ~ docker logs myjenkins
Running from: /usr/share/jenkins/jenkins.war
webroot: EnvVars.masterEnvVars.get("JENKINS_HOME")
2022-01-23 14:58:35.548+0000 [id=1] INFO org.eclipse.jetty.util.log.Log#initialized: Logging initialized @432ms to org.eclipse.jetty.util.log.JavaUtilLog
2022-01-23 14:58:35.616+0000 [id=1] INFO winstone.Logger#logInternal: Beginning extraction from war file
2022-01-23 14:58:50.791+0000 [id=1] WARNING o.e.j.s.handler.ContextHandler#setContextPath: Empty contextPath
2022-01-23 14:58:50.850+0000 [id=1] INFO org.eclipse.jetty.server.Server#doStart: jetty-9.4.43.v20210629; built: 2021-06-30T11:07:22.254Z; git: 526006ecfa3af7f1a27ef3a288e2bef7ea9dd7e8; jvm 11.0.13+8
2022-01-23 14:58:51.470+0000 [id=1] INFO o.e.j.w.StandardDescriptorProcessor#visitServlet: NO JSP Support for /, did not find org.eclipse.jetty.jsp.JettyJspServlet
2022-01-23 14:58:51.561+0000 [id=1] INFO o.e.j.s.s.DefaultSessionIdManager#doStart: DefaultSessionIdManager workerName=node0
2022-01-23 14:58:51.561+0000 [id=1] INFO o.e.j.s.s.DefaultSessionIdManager#doStart: No SessionScavenger set, using defaults
2022-01-23 14:58:51.562+0000 [id=1] INFO o.e.j.server.session.HouseKeeper#startScavenging: node0 Scavenging every 600000ms
2022-01-23 14:58:52.743+0000 [id=1] INFO hudson.WebAppMain#contextInitialized: Jenkins home directory: /var/jenkins_home found at: EnvVars.masterEnvVars.get("JENKINS_HOME")
2022-01-23 14:58:53.216+0000 [id=1] INFO o.e.j.s.handler.ContextHandler#doStart: Started w.@11b455e5{Jenkins v2.331,/,file:///var/jenkins_home/war/,AVAILABLE}{/var/jenkins_home/war}
2022-01-23 14:58:53.249+0000 [id=1] INFO o.e.j.server.AbstractConnector#doStart: Started ServerConnector@6941827a{HTTP/1.1, (http/1.1)}{0.0.0.0:8080}
2022-01-23 14:58:53.249+0000 [id=1] INFO org.eclipse.jetty.server.Server#doStart: Started @18135ms
2022-01-23 14:58:53.250+0000 [id=24] INFO winstone.Logger#logInternal: Winstone Servlet Engine running: controlPort=disabled
2022-01-23 14:58:54.102+0000 [id=31] INFO jenkins.InitReactorRunner$1#onAttained: Started initialization
2022-01-23 14:58:54.205+0000 [id=36] INFO jenkins.InitReactorRunner$1#onAttained: Listed all plugins
2022-01-23 14:58:56.340+0000 [id=32] INFO jenkins.InitReactorRunner$1#onAttained: Prepared all plugins
2022-01-23 14:58:56.350+0000 [id=39] INFO jenkins.InitReactorRunner$1#onAttained: Started all plugins
2022-01-23 14:58:56.370+0000 [id=30] INFO jenkins.InitReactorRunner$1#onAttained: Augmented all extensions
2022-01-23 14:58:57.274+0000 [id=30] INFO jenkins.InitReactorRunner$1#onAttained: System config loaded
2022-01-23 14:58:57.275+0000 [id=32] INFO jenkins.InitReactorRunner$1#onAttained: System config adapted
2022-01-23 14:58:57.275+0000 [id=32] INFO jenkins.InitReactorRunner$1#onAttained: Loaded all jobs
2022-01-23 14:58:57.278+0000 [id=32] INFO jenkins.InitReactorRunner$1#onAttained: Configuration for all jobs updated
2022-01-23 14:58:57.303+0000 [id=53] INFO hudson.model.AsyncPeriodicWork#lambda$doRun$1: Started Download metadata
2022-01-23 14:58:57.339+0000 [id=53] INFO hudson.util.Retrier#start: Attempt #1 to do the action check updates server
WARNING: An illegal reflective access operation has occurred
WARNING: Illegal reflective access by org.codehaus.groovy.reflection.CachedClass (file:/var/jenkins_home/war/WEB-INF/lib/groovy-all-2.4.21.jar) to method java.lang.Object.finalize()
WARNING: Please consider reporting this to the maintainers of org.codehaus.groovy.reflection.CachedClass
WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations
WARNING: All illegal access operations will be denied in a future release
2022-01-23 14:58:58.365+0000 [id=36] INFO jenkins.install.SetupWizard#init:
*************************************************************
*************************************************************
*************************************************************
Jenkins initial setup is required. An admin user has been created and a password generated.
Please use the following password to proceed to installation:
d8722ddc05464738bf0c6c2b4e8922f7
This may also be found at: /var/jenkins_home/secrets/initialAdminPassword
*************************************************************
*************************************************************
*************************************************************
3.5 送信元アドレスの変更
コンテンツの取得が遅い場合は、画像アクセラレーション アドレスを変更してみてください。
ボリュームが構成されているため、コンテナーにログインせずに構成を変更できます。/var/jenkins_mount に移動し
、hudson.model.UpdateCenter.xml を次のように変更します。
<?xml version='1.1' encoding='UTF-8'?>
<sites>
<site>
<id>default</id>
<url>https://mirrors.tuna.tsinghua.edu.cn/jenkins/updates/update-center.json</url>
</site>
</sites>
3.6 メインページにアクセスする
localhost:10240
コンテナ内のアドレスまたはマウントアドレスを入力してパスワードを取得して入力します プラグインを大量にインストールした後、
ここでは管理者ユーザーを設定せず、管理者アカウントを使用しました。