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

如何解决Windows GitLab Runner的Docker错误:invalid condition: 'not-running'?

解决Windows GitLab Runner Docker容器启动报错"invalid condition: 'not-running'"的方案

问题核心原因

该错误源于GitLab Runner 15.x早期版本(如你使用的15.1.0)与Windows Docker环境的兼容性Bug:Runner在检查容器状态时使用了Windows Docker不支持的not-running条件参数,Docker for Windows的容器状态判断逻辑和Linux环境存在差异。

具体修复步骤

1. 升级GitLab Runner至最新稳定版

官方在15.4及以上版本修复了Windows Docker executor的容器状态检查问题:

  • 停止Runner服务:Stop-Service gitlab-runner
  • 下载对应Windows版本的最新Runner安装包覆盖安装
  • 重启服务:Start-Service gitlab-runner

2. 修正Runner配置文件的Shell设置

确保config.toml中Docker executor的Shell适配Windows环境:

  • 打开C:\GitLab-Runner\config.toml
  • 确认executor = "docker-windows"节点下的shell参数设置为"powershell"或"pwsh",避免使用"cmd"
    参考配置片段:
    [[runners]]
      name = "WindowsDockerRunner"
      url = "你的GitLab实例地址"
      token = "wZMWQZYi"
      executor = "docker-windows"
      [runners.docker]
        image = "mcr.microsoft.com/windows/servercore:ltsc2019"
        shell = "powershell"
    

3. 确认Docker Desktop处于Windows容器模式

  • 右键任务栏Docker图标,选择Switch to Windows containers(当前为Linux容器模式时切换)
  • 重启Docker Daemon后,本地测试容器启动:docker run -it mcr.microsoft.com/windows/servercore:ltsc2019 powershell,验证是否能正常进入Shell

4. 清理残留的Runner缓存容器

残留的失效容器可能干扰任务运行:

  • 停止所有Runner相关容器:docker stop $(docker ps -q --filter "name=runner-*")
  • 删除这些容器:docker rm $(docker ps -aq --filter "name=runner-*")

内容的提问来源于stack exchange,提问作者Josh Correia

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.08.23 11:48:19