You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

向image.run()添加命令后Docker ps输出为空的问题

Troubleshooting Selenoid Container Creation Failure in Jenkins Pipeline

Let's break down your issue step by step, starting with context around your environment and then diving into actionable fixes that should get your Selenoid container running with custom commands.

Environment Context

  • Docker Plugin version: 1.1.2
  • Jenkins version: 2.0.50727
  • Docker Client/Server version: 17.12.0-ce
  • Host OS: Windows 10 Pro x64

Reproducible Scenarios

  1. Working Case: When you run the Selenoid image via your Jenkinsfile without adding any custom commands to image.run(), the container spins up successfully and appears in docker ps output—no issues here.
  2. Failing Case: As soon as you append a custom command (like -video-output-dir /output) to image.run(), the container never gets created at all. docker ps returns empty, meaning the command either fails silently or exits immediately.

Why This Happens

The core issue is almost certainly tied to how the outdated Docker plugin handles command arguments, especially on a Windows host:

  • Argument Parsing Bugs: Docker plugin 1.1.2 is quite old, and it has known flaws splitting command strings into valid Docker arguments. Passing -video-output-dir /output as a single string might cause the plugin to send it to Docker as one argument (instead of two separate ones: the flag and its value), which Docker can't interpret correctly.
  • Windows Path/Quoting Conflicts: Even though Selenoid runs in a Linux container, Jenkins (running on Windows) might mishandle argument escaping or path formatting when passing commands to the Docker daemon.
  • Version Compatibility: Docker 17.12.0-ce is newer than the 1.1.2 plugin, and there are compatibility gaps between older plugin versions and more recent Docker releases.

Fixes to Implement

Here are the most reliable solutions to get your custom commands working:

  1. Pass Arguments as Separate List Items
    Instead of passing the command as a single string, split each flag and its value into separate arguments in the run() method. This ensures the plugin parses them correctly. For example:

    docker.image('aerokube/selenoid').run('-d', '-video-output-dir', '/output')
    

    If you need to add more flags (like volume mounts), keep each pair as separate elements:

    docker.image('aerokube/selenoid').run(
      '-d',
      '-v', 'C:/selenoid/videos:/output', // Windows host path mapped to container /output
      '-video-output-dir', '/output'
    )
    
  2. Test the Docker Command Directly
    To rule out plugin-specific issues, run the exact Docker command in a sh step in your Jenkinsfile. This will tell you if the command works outside the plugin context:

    sh "docker run -d aerokube/selenoid -video-output-dir /output"
    

    If this works and the container shows up in docker ps, the problem is definitely with how the plugin is handling the arguments.

  3. Upgrade the Docker Plugin
    The simplest long-term fix is to upgrade your Docker plugin to a newer stable version. The 1.1.2 version has dozens of bug fixes related to argument parsing and Windows compatibility in later releases. Upgrading will resolve most of these edge cases automatically.

  4. Check for Immediate Container Exits
    If the container is created but exits immediately (which is why docker ps doesn't show it), run docker ps -a to see stopped containers. Check the logs with docker logs <container-id> to see if Selenoid is throwing an error about the -video-output-dir flag (like missing permissions or an invalid path).

内容的提问来源于stack exchange,提问作者Maksim Gerasimenko

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.19 08:31:46