【发布时间】:2021-02-03 05:18:24
【问题描述】:
问题
我正在使用 Docker 镜像jenkinsci/jnlp-slave:4.3-1。
我尝试像这样从docker run 执行命令:
docker run --rm jenkinsci/jnlp-slave:4.3-1 cat /etc/os-release
但是,该命令似乎没有以通常的方式执行。 例如上面的命令导致错误:
$docker run --rm jenkinsci/jnlp-slave:4.3-1 cat /etc/os-release
At least one -url option is required.
java -jar agent.jar [options...] <secret key> <agent name>
-agentLog FILE : Local agent error log destination
(overrides workDir)
-cert VAL : Specify additional X.509 encoded PEM
certificates to trust when connecting
to Jenkins root URLs. If starting with
@ then the remainder is assumed to be
the name of the certificate file to
read.
-credentials USER:PASSWORD : HTTP BASIC AUTH header to pass in for
making HTTP requests.
-direct (-directConnection) HOST:PORT : Connect directly to this TCP agent
port, skipping the HTTP(S) connection
parameter download. For example,
"myjenkins:50000".
-disableHttpsCertValidation : Ignore SSL validation errors - use as
a last resort only. (default: false)
-failIfWorkDirIsMissing : Fails the initialization if the
requested workDir or internalDir are
missing ('false' by default) (default:
false)
-headless : Run agent in headless mode, without
GUI (default: false)
-help : Show this help message (default: false)
-instanceIdentity VAL : The base64 encoded InstanceIdentity
byte array of the Jenkins master. When
this is set, the agent skips
connecting to an HTTP(S) port for
connection info.
-internalDir VAL : Specifies a name of the internal files
within a working directory ('remoting'
by default) (default: remoting)
-jar-cache DIR : Cache directory that stores jar files
sent from the master
-loggingConfig FILE : Path to the property file with
java.util.logging settings
-noKeepAlive : Disable TCP socket keep alive on
connection to the master. (default:
false)
-noreconnect : If the connection ends, don't retry
and just exit. (default: false)
-protocols VAL : Specify the remoting protocols to
attempt when instanceIdentity is
provided.
-proxyCredentials USER:PASSWORD : HTTP BASIC AUTH header to pass in for
making HTTP authenticated proxy
requests.
-tunnel HOST:PORT : Connect to the specified host and
port, instead of connecting directly
to Jenkins. Useful when connection to
Jenkins needs to be tunneled. Can be
also HOST: or :PORT, in which case the
missing portion will be auto-configured
like the default behavior
-url URL : Specify the Jenkins root URLs to
connect to.
-version : Shows the version of the remoting jar
and then exits (default: false)
-webSocket : Make a WebSocket connection to Jenkins
rather than using the TCP port.
(default: false)
-workDir FILE : Declares the working directory of the
remoting instance (stores cache and
logs by default)
预期行为
我尝试过使用不同的图像,例如 ubuntu:21.04。
命令以正常方式执行,如下所示:
$docker run --rm ubuntu:21.04 cat /etc/os-release
NAME="Ubuntu"
VERSION="21.04 (Hirsute Hippo)"
ID=ubuntu
ID_LIKE=debian
PRETTY_NAME="Ubuntu Hirsute Hippo (development branch)"
VERSION_ID="21.04"
HOME_URL="https://www.ubuntu.com/"
SUPPORT_URL="https://help.ubuntu.com/"
BUG_REPORT_URL="https://bugs.launchpad.net/ubuntu/"
PRIVACY_POLICY_URL="https://www.ubuntu.com/legal/terms-and-policies/privacy-policy"
VERSION_CODENAME=hirsute
UBUNTU_CODENAME=hirsute
问题
- 我想知道为什么一个简单的 Linux 命令会根据映像生成不同的结果。
命令
cat /etc/os-release在以不同方式执行时运行良好,如下所示:$docker run --rm -it jenkinsci/jnlp-slave:4.3-1 /bin/bash jenkins@4a7d91e19e3a:~$ cat /etc/os-release PRETTY_NAME="Debian GNU/Linux 10 (buster)" NAME="Debian GNU/Linux" VERSION_ID="10" VERSION="10 (buster)" VERSION_CODENAME=buster ID=debian HOME_URL="https://www.debian.org/" SUPPORT_URL="https://www.debian.org/support" BUG_REPORT_URL="https://bugs.debian.org/" - 是否可以使用
jenkinsci/jnlp-slave:4.3-1执行来自docker run的命令?
【问题讨论】: