# Agent in step cannot override global docker agent?

**URL:** <https://community.jenkins.io/t/agent-in-step-cannot-override-global-docker-agent/37009>\
**Category:** Ask a question\
**Created:** [May 18, 2026, 1:32pm UTC](https://community.jenkins.io/t/agent-in-step-cannot-override-global-docker-agent/37009 "2026-05-18T13:32:03Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Vilius](https://dub1.discourse-cdn.com/flex013/user_avatar/community.jenkins.io/vilius/32/2080_2.png) [@Vilius](https://community.jenkins.io/u/Vilius)\
**Post date:** [May 18, 2026, 1:32pm UTC](https://community.jenkins.io/t/agent-in-step-cannot-override-global-docker-agent/37009/1 "2026-05-18T13:32:03Z")

</div>

I have a pipeline where multiple stages of tests are run using customized testing Docker image. I’m trying to override an agent in one of the stages so that `kubectl` commands in it could be run on the Jenkins node itself, instead of container:

```java
pipeline {
  agent {
    docker {
      image 'mycustomimage'
      registryUrl 'https://mycustomregistry'
    }
  }
  stages {
    stage('restart gateway before tests') {
      agent any
      steps {
        script {
          withKubeConfig([credentialsId: 'kubernetes', namespace: 'default', restrictKubeConfigAccess: true]) {
            sh "kubectl rollout restart deploy/gateway"
          }
        }
      }
    }
    stage('Run tests stage 1') {
      steps {
        script {
          echo "bla1"
        }
      }
    }
    stage('Run other tests stage 2') {
      steps {
        script {
          echo "bla2"
        }
      }
    }
  }
}

```

This always results in the hanged pipeline just after `kubectl` command is executed:

```auto
process apparently never started in /srv/jenkins/workspace/regression-testing_PR-701@2@tmp/durable-7d760c52

```

Also, at the beginning of the run I always see this message:

```auto
Warning: JENKINS-30600: special launcher org.jenkinsci.plugins.docker.workflow.WithContainerStep$Decorator$1@19960d70; decorates hudson.Launcher$LocalLauncher@3503c55d will be ignored (a typical symptom is the Git executable not being run inside a designated container)

```

If I set global agent to `agent any` and then override agent to Docker image in the test stages, it works. However, I don’t want to override this way as I have multiple testing stages and I don’t want to repeat Docker agent configuration for all of them.

Is this a bug, or you cannot override container agents at all?

---

<div class="post-metadata">

**Author:** ![bpedersen2](https://dub1.discourse-cdn.com/flex013/user_avatar/community.jenkins.io/bpedersen2/32/367_2.png) [@bpedersen2](https://community.jenkins.io/u/bpedersen2)\
**Post date:** [May 21, 2026, 6:51am UTC](https://community.jenkins.io/t/agent-in-step-cannot-override-global-docker-agent/37009/2 "2026-05-21T06:51:39Z")

</div>

`Agent any` is satisfied by the image based agent already in use, you need to explicitly request a real node or a node label.

---

<div class="post-metadata">

**Author:** ![Vilius](https://dub1.discourse-cdn.com/flex013/user_avatar/community.jenkins.io/vilius/32/2080_2.png) [@Vilius](https://community.jenkins.io/u/Vilius)\
**Post date:** [June 29, 2026, 2:52pm UTC](https://community.jenkins.io/t/agent-in-step-cannot-override-global-docker-agent/37009/3 "2026-06-29T14:52:47Z")

</div>

Thank you @bpedersen2. I did think that `any` would mean that Docker agent is satisfied, but unable to run on it for some reason. Setting `agent { label 'my label' }` in the desired stage overrides global docker agent perfectly!

Do you know if it is possible to specify any agent which has “standard host” node type, i.e. not Docker agents? We don’t use labels at the moment so I’m thinking do we need to actually label all our nodes, or I’ve missed anything hidden in the documentation?
