<p>How I can change securityContext of my pods in Jenkins Kubernetes Plugin. For example, run docker in docker images with privileged mode in docker environment. </p>

<p>I believe <a href="https://github.com/jenkinsci/kubernetes-plugin#using-yaml-to-define-pod-templates" rel="nofollow noreferrer">this</a> should work (as per the docs):</p>

<pre><code>def label = "mypod-${UUID.randomUUID().toString()}"
podTemplate(label: label, yaml: """
apiVersion: v1
kind: Pod
metadata:
  labels:
    some-label: some-label-value
spec:
  containers:
  - name: busybox
    image: busybox
    command:
    - cat
    tty: true
    securityContext:
      allowPrivilegeEscalation: true
"""
) {
    node (label) {
      container('busybox') {
        sh "hostname"
      }
    }
}
</code></pre>
