Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to make regular use of Windows Docker Agent Mirror

2025-02-22 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/01 Report--

How to carry out the routine use of Windows Docker Agent images, I believe that many inexperienced people do not know what to do, so this article summarizes the causes of the problem and solutions, through this article I hope you can solve this problem.

We would like to announce the availability of official Windows agent Docker images, which allow Jenkins agent to be configured using the Windows operating system on Docker and Kubernetes.

New Mirror

All official Docker images of agent now provide nanoserver-1809 and windowsservercore-1809 tags, including the Windows image and the current Java 8 (similar to the latest tag). We also provide clear Java options, such as jdk8-windowsservercore-1809 or jdk11-nanoserver-1809. Version tags are also available, such as jenkins/agent:4.3-4-jdk8-nanoserver-1809.

Jenkins/agent is a basic agent that bundles agent.jar for communication between agent master and, most useful, can be used as a base image for other mirrors. Windows images are available from version 4.3-4.

Jenkins/inbound-agent is an agent based on the above jenkins/agent image, which provides wrapper class scripts written in PowerShell to help specify parameters for agent.jar. Windows images are available from version 4.3-4.

Jenkins/ssh-agent is an image with OpenSSH installed and should be used with SSH Build Agents Plugin. Windows images have been available since version 2.1.0.

Use Windows Docker mirroring

To use the new image, you will need an appropriate Docker or Kubernetes environment that supports running the Windows container. For Windows desktop users, the easiest way is to use Docker for Windows. Kubernetes's support for Windows is documented here.

Jenkins/agent

The jenkins/agent image is a simple agent of JDK and agent.jar (the Jenkins Remoting library).

This image has two main uses:

As the base image for other Docker images (such as FROM jenkins/agent:jdk8-nanoserver-1809 in Dockerfile), jenkins/inbound-agent is based on this image.

The image can also be used to start agent through _ Launch method_ of _ Launch agent via execution of command on the master_, which allows the master server to automatically start agent within the docker container.

To run agent for the second purpose, after setting _ Remote root directory_ to C:\ Users\ jenkins\ agent, specify the following command on the Jenkins primary server:

Docker run-I-- rm-- name agent-- init jenkins/agent:jdk8-windowsservercore-1809 java-jar C:/ProgramData/Jenkins/agent.jarjenkins/inbound-agent

The inbound-agent Docker image attempts to provide a higher level of interaction with the agent.jar executable. It provides a PowerShell wrapper class script around agent.jar and is specified as the entry point, so you only need to pass a few command-line arguments to run agent. A pull request has been opened that records these command-line arguments and environment variables.

Example:

Docker run jenkins/inbound-agent:windowsservercore-1809 `- Url http://jenkins-server:port`-WorkDir=C:/Users/jenkins/Agent `- Secret`-Name

An example of using environment variables:

Docker run-e "JENKINS_URL= http://jenkins-server:port"-e" JENKINS_AGENT_NAME=AGENTNAME "`jenkins/inbound-agent:windowsservercore-1809 `- WorkDir=C:/Users/jenkins/Agent`-Secret `- Name Note:-Url,-Name and-Secret are required parameters, but can be specified as command line arguments or environment variables. Jenkins/ssh-agent

As mentioned above, the jenkins/ssh-agent docker mirror is based on SSH communication with the host, not on the remote TCP or WebSocket protocol. The image sets up a jenkins user and an OpenSSH server so that the primary server can connect to the agent through SSH. The image requires the SSH public key as a parameter, and the key is placed in the jenkins user's authorized_keys file. The private key should be specified in the agent configuration on the primary server to allow the primary server to connect.

Example:

Docker run jenkins/ssh-agent:jdk8-windowsservercore-1809 ""

When using docker run, you can also pass the public key as an environment variable.

Example:

Docker run-e "JENKINS_AGENT_SSH_PUBKEY=" jenkins/ssh-agent:jdk8-windowsservercore-1809

You will then be able to connect the agent as a "jenkins" using SSH Build Agents Plugin with the matching private key.

After reading the above, have you mastered how to carry out the general use of Windows Docker Agent images? If you want to learn more skills or want to know more about it, you are welcome to follow the industry information channel, thank you for reading!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report