DOCKER PIPELINE PLUGIN: CONTAINER AGENTS, WORKSPACES & ISOLATION

Industrial reference and architectural manual for B.Tech Cloud & DevOps Engineers and Infrastructure Architects: Containerized step isolation, the agent { docker { ... } } directive, host workspace volume binding, dynamic UID/GID synchronization, sidecar container networking, registry credentials binding, and the Docker-in-Docker dilemma.

🐳 Ephemeral Tool Isolation: Eliminating the "Snowflake Agent" Anti-Pattern

In traditional CI/CD clusters, build agents suffer from configuration drift: distinct teams install conflicting JDK versions, divergent Node.js engines, global npm modules, and inconsistent compiler toolchains on shared agent virtual machines. This "snowflake agent" architecture inevitably creates fragile, non-reproducible pipelines. The Docker Pipeline Plugin (docker-workflow) replaces monolithic host installations with clean, ephemeral container environments. By declaring agent { docker { image '...' } } or agent { dockerfile true }, the pipeline dynamically launches an OCI container on the host Docker daemon, mounts the build workspace into the container, maps process user IDs (UID/GID) to prevent filesystem lockouts, executes stages inside pristine runtime containers, and destroys the container upon stage completion.

1. Architecture of Docker Agent Execution: The Host-to-Container Bridge
Examining the mechanical lifecycle of how Jenkins orchestrates containers: Socket communication, automatic workspace bind-mounting, entrypoint overrides, and PID lifecycle tracking.
ASCII Architecture: Host Remoting Daemon to Container Execution Bridge
DOCKER PIPELINE EXECUTION LIFECYCLE & BIND-MOUNTING:

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚                              JENKINS HOST AGENT (LINUX VM / EC2)                         β”‚
β”‚                                                                                          β”‚
β”‚  1. Remoting Subsystem (remoting.jar running as 'jenkins' UID:1000, GID:1000)            β”‚
β”‚  2. Pipeline Workspace Path: /var/jenkins/workspace/payment-service                      β”‚
β”‚  3. Docker CLI Client issues command to local Docker Daemon (/var/run/docker.sock):      β”‚
β”‚                                                                                          β”‚
β”‚     docker run -d -t \                                                                   β”‚
β”‚       -u 1000:1000 \                                                                     β”‚
β”‚       -w /var/jenkins/workspace/payment-service \                                        β”‚
β”‚       -v /var/jenkins/workspace/payment-service:/var/jenkins/workspace/payment-service \ β”‚
β”‚       -v /var/jenkins/caches:/root/.m2 \                                                 β”‚
β”‚       --entrypoint cat \                                                                 β”‚
β”‚       maven:3.9.6-eclipse-temurin-17                                                     β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                                           β”‚
                                           β”‚ Forks Container Instance & Mounts Workspace
                                           β–Ό
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚                       EPHEMERAL RUNTIME CONTAINER (MAVEN 3.9.6)                        β”‚
β”‚                                                                                        β”‚
β”‚  Container ID: c8f3a12b4e90...                                                         β”‚
β”‚  Status: Kept alive via standard input daemon: 'cat' command                           β”‚
β”‚                                                                                        β”‚
β”‚  Step Execution via Docker Exec:                                                       β”‚
β”‚  β€’ Host Remoting executes: docker exec -u 1000:1000 c8f3a1... sh -c "mvn clean test"   β”‚
β”‚  β€’ Reads source code from bind-mounted workspace.                                      β”‚
β”‚  β€’ Compiles bytecode; writes .class and .jar directly to Host filesystem!              β”‚
β”‚                                                                                        β”‚
β”‚  Stage Completion:                                                                     β”‚
β”‚  β€’ Host executes: docker stop c8f3a1... && docker rm -f c8f3a1...                      β”‚
β”‚  β€’ Workspace remains intact on host; ephemeral container vanished completely.          β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
Architectural Standard: The Docker Pipeline plugin does NOT package Jenkins remoting inside the target image. It runs standard, unmodified public Docker images (like python, node, maven, or golang) by launching them with '--entrypoint cat' in detached mode, using 'docker exec' to execute build steps inside the container environment.
2. Declarative agent { docker { ... } } Syntax & Topologies
Complete syntax reference for declarative container agents: Specifying runtime images, custom container arguments, volume caches, reuseNode optimization, and global vs. stage-level execution.
Groovy (Declarative Pipeline with Docker Agent Options & Volume Caches)
// Declarative Pipeline: Production Docker Agent Configuration
pipeline {
    // 1. GLOBAL AGENT NONE: Allows individual stages to claim isolated tool containers
    agent none

    options {
        timeout(time: 30, unit: 'MINUTES')
        timestamps()
    }

    stages {
        // 2. STAGE 1: COMPILATION & TESTING IN MAVEN CONTAINER
        stage('Java Backend Compile & Test') {
            agent {
                docker {
                    image 'maven:3.9.6-eclipse-temurin-17'
                    label 'docker-capable-host' // Runs on agents tagged with 'docker-capable-host'
                    // Mount host cache directories to prevent re-downloading dependencies on every build!
                    args '-v /var/cache/jenkins/m2:/root/.m2 -v /etc/hosts:/etc/hosts:ro'
                    alwaysPull true              // Guarantees latest container digest from registry
                    reuseNode true               // Reuses existing workspace instead of re-allocating
                }
            }
            steps {
                echo "[*] Compiling backend inside isolated Maven container..."
                sh 'java -version'
                sh 'mvn -version'
                sh 'mvn clean test -Dmaven.repo.local=/root/.m2/repository'
            }
            post {
                always {
                    junit 'target/surefire-reports/*.xml'
                }
            }
        }

        // 3. STAGE 2: FRONTEND COMPILATION IN NODE.JS CONTAINER
        stage('Frontend Webpack & Lint') {
            agent {
                docker {
                    image 'node:20-alpine'
                    label 'docker-capable-host'
                    args '-v /var/cache/jenkins/npm:/root/.npm'
                    reuseNode true
                }
            }
            steps {
                echo "[*] Compiling frontend assets inside Node.js Alpine container..."
                sh 'node --version'
                sh 'npm --version'
                sh 'npm ci --cache /root/.npm'
                sh 'npm run build'
            }
        }
    }
}
Console Execution Log: [Pipeline] { (Java Backend Compile & Test) [Pipeline] docker pull maven:3.9.6-eclipse-temurin-17 [Pipeline] docker run -d -t -u 1000:1000 -w /var/jenkins/workspace/payment-service -v /var/jenkins/workspace/payment-service:/var/jenkins/workspace/payment-service -v /var/cache/jenkins/m2:/root/.m2 maven:3.9.6-eclipse-temurin-17 cat [Pipeline] docker exec c8f3a1... java -version openjdk version "17.0.10" 2024-01-16 [Pipeline] docker stop c8f3a1... && docker rm -f c8f3a1... [Pipeline] } // stage
3. Workspace Permissions & The UID/GID Synchronization Mechanism
Resolving the "Permission Denied" file trap: How the plugin automatically passes -u $(id -u):$(id -g), rootless container behaviors, and handling Alpine root users.
Permission Synchronization Lifecycle & Conflict Resolution
THE UID/GID WORKSPACE PERMISSION TRAP & AUTOMATED FIX:

1. THE STANDARD DOCKER PERMISSION DEFECT (WITHOUT THE PLUGIN):
   β€’ An engineer runs: docker run -v $(pwd):/app maven:latest mvn package
   β€’ By default, Docker containers execute processes as ROOT (UID 0, GID 0).
   β€’ The container creates: target/application.jar owned by root:root (rw-r--r--).
   β€’ Build completes; Jenkins tries to run cleanWs() or post-actions as 'jenkins' user (UID 1000).
   β€’ CATASTROPHE: java.io.IOException: Permission denied: Unable to delete target/application.jar!

2. HOW THE DOCKER PIPELINE PLUGIN RESOLVES PERMISSIONS AUTOMATICALLY:
   When Jenkins launches the container, it dynamically queries the host user's ID:
   HOST_UID=$(id -u jenkins) βž” 1000
   HOST_GID=$(id -g jenkins) βž” 1000

   It automatically appends the execution flag:
   -u 1000:1000

   Outcome: Any file generated inside the container by Maven, npm, or gcc is created with
   ownership 1000:1000, matching the host 'jenkins' user identically!

3. THE ROOT-ONLY IMAGE EXCEPTION (ALPINE / CUSTOM APPLIANCES):
   Some images (like raw Alpine or security tools) crash if run as non-root because they
   lack /etc/passwd entries for UID 1000 or require root rights to bind ports.
   Remediation: Explicitly override the user flag in the 'args' directive:

   agent {
       docker {
           image 'aquasec/trivy:latest'
           // Force root execution inside container; remap permissions after run
           args '-u 0:0 -v /var/run/docker.sock:/var/run/docker.sock'
       }
   }
Security Precaution: When running containers with '-u 0:0' (root), ensure you clean up root-owned build outputs inside the container before the stage ends (e.g., sh 'chown -R 1000:1000 target/'), otherwise subsequent non-root stages and cleanup hooks will fail with permission denied errors.
4. On-the-Fly Image Generation: The agent { dockerfile { ... } } Directive
Building and running bespoke test environments on the fly: Building from a local Dockerfile committed directly in the source repository without pre-publishing to an external registry.
Groovy (Declarative Pipeline Building Dynamic Environment via Local Dockerfile)
// Production Declarative Pipeline: Dynamic In-Repo Dockerfile Agent
pipeline {
    agent {
        // Instructs Jenkins to locate, build, and launch a container from a repository Dockerfile
        dockerfile {
            filename 'ci/Dockerfile.build'      // Path relative to repository root
            dir 'ci'                           // Build context directory
            label 'docker-capable-host'         // Target agent node with Docker daemon
            additionalBuildArgs '--build-arg TOOL_VERSION=3.2.0 --no-cache'
            args '-v /tmp/custom-cache:/cache'
            reuseNode true
        }
    }

    stages {
        stage('Verify Custom Toolchain') {
            steps {
                echo "[*] Executing inside dynamically built bespoke container environment..."
                sh '''
                    cat /etc/os-release
                    custom-compiler-cli --version
                    make test-all
                '''
            }
        }
    }
}
Dockerfile (ci/Dockerfile.build: Committed alongside source code)
# ci/Dockerfile.build - Committed directly to Git repository
FROM ubuntu:22.04

ARG TOOL_VERSION=3.2.0
ENV DEBIAN_FRONTEND=noninteractive

# Install specialized C++ and Python testing toolchains
RUN apt-get update && apt-get install -y \
    curl \
    git \
    build-essential \
    python3-pip \
    clang-format \
    && rm -rf /var/lib/apt/lists/*

# Install specific proprietary testing binary
RUN echo "Installing testing toolchain version: ${TOOL_VERSION}"
Pipeline Build Log: [Pipeline] { (Verify Custom Toolchain) [Pipeline] sh + docker build -t c3b1a0... -f ci/Dockerfile.build --build-arg TOOL_VERSION=3.2.0 --no-cache ci Sending build context to Docker daemon 4.096kB Step 1/4 : FROM ubuntu:22.04 ... Successfully tagged c3b1a0... [Pipeline] docker run -d -t -u 1000:1000 c3b1a0... cat [Pipeline] docker exec 8f9b... custom-compiler-cli --version Custom Compiler v3.2.0 [Build Verified]
5. Private Container Registries & Authentication: withRegistry() Helper
Pulling and running proprietary enterprise container images: Authenticating against AWS ECR, Docker Hub, Harbor, and Sonatype Nexus using credentialsBinding.
Groovy (Declarative & Scripted Authenticated Container Registry Interactions)
// 1. DECLARATIVE PIPELINE: Pulling Agent from Private Authenticated Registry
pipeline {
    agent {
        docker {
            image 'harbor.company.com/engineering/secure-build-node:v4.2'
            label 'docker-capable-host'
            // Credential ID must match 'Username with password' or 'Secret text' in Jenkins
            registryCredentialsId 'harbor-enterprise-token'
            registryUrl 'https://harbor.company.com'
        }
    }
    stages {
        stage('Execute Inside Secure Enterprise Image') {
            steps {
                sh 'security-audit-tool --scan .'
            }
        }
    }
}

// ─────────────────────────────────────────────────────────────────────────────

// 2. SCRIPTED PIPELINE: Dynamic withRegistry Wrapper
node('docker-capable-host') {
    stage('Pull & Execute via withRegistry') {
        // Authenticates against registry, writes temporary auth token, scrubs on exit
        docker.withRegistry('https://registry.company.com', 'private-registry-credentials') {
            def customImage = docker.image('registry.company.com/tools/python-builder:3.11')
            
            // Pull latest image using stored credentials
            customImage.pull()

            // Run execution closure inside the container
            customImage.inside('-v /var/run/docker.sock:/var/run/docker.sock') {
                sh 'python3 -m unittest discover'
            }
        }
    }
}
Authentication Security: The 'docker.withRegistry' block executes an automated 'docker login' writing an ephemeral credentials file, maps that configuration into the container execution, and automatically executes 'docker logout' in a finally block to ensure credentials are never left on the host.
6. Sidecar Containers & Service Networking: docker.image().withRun()
Running ephemeral backend dependencies in parallel: Spawning Redis, PostgreSQL, or Kafka sidecar containers and connecting them to the test execution container.
Groovy (Orchestrating Ephemeral Database Sidecars for Integration Testing)
// Scripted Pipeline / script {} block: Multi-Container Sidecar Orchestration
pipeline {
    agent { label 'docker-capable-host' }

    stages {
        stage('Database Integration Suite') {
            steps {
                script {
                    echo "[*] Provisioning isolated bridge network for multi-container tests..."
                    def networkName = "ci-net-${env.BUILD_TAG}"
                    sh "docker network create ${networkName}"

                    try {
                        // 1. LAUNCH POSTGRESQL SIDECAR CONTAINER
                        def postgres = docker.image('postgres:15-alpine')
                        postgres.withRun("--network=${networkName} --network-alias=postgres-db -e POSTGRES_PASSWORD=secret_ci_pass -e POSTGRES_DB=testdb") { pgContainer ->
                            
                            // 2. LAUNCH REDIS SIDECAR CONTAINER
                            def redis = docker.image('redis:7-alpine')
                            redis.withRun("--network=${networkName} --network-alias=redis-cache") { redisContainer ->
                                
                                echo "[+] Sidecars running: Postgres (${pgContainer.id.take(7)}) | Redis (${redisContainer.id.take(7)})"

                                // 3. LAUNCH TEST RUNNER CONTAINER INSIDE SAME NETWORK
                                def testRunner = docker.image('maven:3.9.6-eclipse-temurin-17')
                                testRunner.inside("--network=${networkName}") {
                                    echo "[*] Executing integration tests against connected sidecars..."
                                    sh '''
                                        # Resolves Postgres & Redis via Docker internal DNS network aliases!
                                        nc -zv postgres-db 5432
                                        nc -zv redis-cache 6379
                                        mvn test -Dtest=DatabaseIntegrationTestSuite
                                    '''
                                }
                            }
                        }
                    } finally {
                        echo "[*] Cleaning up isolated bridge network..."
                        sh "docker network rm ${networkName} || true"
                    }
                }
            }
        }
    }
}
Container Networking Advantage: The 'withRun()' block spawns detached background daemon containers. By connecting the sidecars and test runner to a dedicated bridge network ('ci-net-${env.BUILD_TAG}'), the application communicates with dependencies using clear DNS hostnames ('postgres-db' and 'redis-cache') rather than fragile host port mappings (localhost:5432) that collide when builds run concurrently.
7. Scripted Pipeline Equivalence: The .inside() Primitive
Deep dive into the underlying engine powering the Docker Pipeline plugin: Understanding how docker.image('...').inside { ... } executes steps and handles closures.
Groovy (Scripted Pipeline: Advanced .inside() Syntax & Custom Volume Mounts)
node('docker-capable-host') {
    stage('Checkout') {
        checkout scm
    }

    stage('Execute Steps in Parallel Tool Containers') {
        def appWorkspace = pwd()
        echo "Active Host Workspace: ${appWorkspace}"

        // Pull container image
        def golangImage = docker.image('golang:1.22-alpine')
        golangImage.pull()

        // .inside() launches container, mounts pwd(), sets UID/GID, runs closure, kills container
        golangImage.inside('-e CGO_ENABLED=0 -v /var/cache/go-pkg:/go/pkg/mod') {
            stage('Compile Go Microservice') {
                sh 'go version'
                sh 'go env'
                sh 'go build -v -o target/payment-engine ./cmd/...'
            }
        }

        def alpineSecurity = docker.image('alpine:latest')
        alpineSecurity.inside {
            stage('Verify Binary Immutability') {
                sh 'ls -lh target/payment-engine'
                sh 'file target/payment-engine || true'
            }
        }
    }
}
How .inside() Operates: 1. Calls 'docker run -d -t -u <uid>:<gid> -v <host-workspace>:<host-workspace> ... <image> cat' 2. Intercepts all 'sh' and 'bat' steps declared inside the Groovy closure. 3. Wraps them in 'docker exec <container-id> sh -c "..."' 4. When the closure exits (normally or via an error), executes 'docker stop' and 'docker rm -f'.
8. Common Pitfalls & Troubleshooting Docker Pipeline Agents
Diagnostic guide for resolving frequent Docker Pipeline failure modes: Socket permission denied, missing sh/cat binaries in scratch containers, and memory limits.
Troubleshooting Playbook & Diagnostic Failure Analysis
COMMON DOCKER PIPELINE DEFECTS & REMEDIATIONS:

1. ERROR: "Got permission denied while trying to connect to the Docker daemon socket"
   β€’ Symptom: Pipeline fails instantly on agent allocation with exit code 1.
   β€’ Root Cause: The host 'jenkins' user running remoting.jar is not a member of the host 'docker' group.
   β€’ Remediation:
     sudo usermod -aG docker jenkins
     sudo systemctl restart jenkins-agent (or restart SSH remoting connection).

2. ERROR: "Cannot run program 'docker': error=2, No such file or directory"
   β€’ Cause: The Docker CLI binary is either not installed on the worker host or /usr/bin/docker
     is missing from the system PATH of the non-interactive SSH shell.
   β€’ Remediation: Install docker-ce-cli on the host, or export PATH in Manage Jenkins βž” Node properties.

3. ERROR: "Cannot run program 'cat': error=2, No such file or directory" (SCRATCH IMAGES)
   β€’ Cause: The pipeline specifies a minimal image (like 'scratch' or a distroless container)
     that does not contain '/bin/sh' or '/bin/cat'.
   β€’ Explanation: The Docker Pipeline plugin REQUIRES 'cat' to keep the container open and 'sh'
     to execute commands.
   β€’ Remediation: You CANNOT use scratch or distroless images as build agents! Use images containing
     at least a minimal POSIX shell (e.g. alpine, debian-slim, or ubi-minimal).

4. DOCKER DISK EXHAUSTION (NO SPACE LEFT ON DEVICE):
   β€’ Cause: 'alwaysPull true' pulls fresh container layers continuously; dangling images accumulate.
   β€’ Remediation: Configure an automated nightly cron maintenance script on the host agent:
     docker system prune -af --filter "until=72h" --volumes
Diagnostic Command: To verify that the host agent can execute Docker commands under the exact user context Jenkins uses, run this command on the agent host terminal: sudo -u jenkins docker run --rm hello-world
9. Technical Specification & Examination Reference Matrix
A structured engineering reference matrix comparing Docker agent directives, parameter options, lifecycle hooks, and exam definitions for B.Tech students.
Docker Pipeline Technical Specification Reference Matrix
DOCKER PIPELINE PLUGIN SPECIFICATION MATRIX:
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚ DIRECTIVE / PARAMETER   β”‚ VALID PARENT SCOPE           β”‚ OPERATIONAL FUNCTION                    β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚ agent { docker { } }    β”‚ pipeline root, stage         β”‚ Spawns container from pre-built image   β”‚
β”‚ agent { dockerfile { } }β”‚ pipeline root, stage         β”‚ Builds container from local Dockerfile  β”‚
β”‚ image                   β”‚ docker {} block              β”‚ OCI image name (e.g. maven:3.9)         β”‚
β”‚ args                    β”‚ docker {}, dockerfile {}     β”‚ Flags passed to 'docker run'            β”‚
β”‚ alwaysPull true         β”‚ docker {} block              β”‚ Forces 'docker pull' before run         β”‚
β”‚ reuseNode true          β”‚ docker {}, dockerfile {}     β”‚ Reuses existing workspace directory     β”‚
β”‚ registryUrl             β”‚ docker {} block              β”‚ Private container registry endpoint     β”‚
β”‚ registryCredentialsId   β”‚ docker {} block              β”‚ Credentials store token/user identifier β”‚
β”‚ docker.withRegistry()   β”‚ Scripted pipeline, script{}  β”‚ Ephemeral authenticated registry wrapperβ”‚
β”‚ docker.image().inside() β”‚ Scripted pipeline, script{}  β”‚ Executes closure inside container       β”‚
β”‚ docker.image().withRun()β”‚ Scripted pipeline, script{}  β”‚ Spawns detached sidecar container       β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚ TOP 5 CORE DOCKER PIPELINE AXIOMS FOR DEVOPS SREs:                                               β”‚
β”‚ 1. Mount Host Caches: Use '-v /host/cache:/container/cache' to prevent re-downloading modules    β”‚
β”‚ 2. Avoid Monolithic Toolchains: Use specialized single-purpose container images per stage.       β”‚
β”‚ 3. Never Use Scratch as Agents: Build agents require a POSIX shell ('sh') and 'cat' binary.      β”‚
β”‚ 4. Isolate Sidecar Networks: Always create dedicated bridge networks for multi-container tests   β”‚
β”‚ 5. Audit Host Disk Usage: Schedule regular 'docker system prune' sweeps to prevent disk locks.   β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
Academic & Professional Standard: The Docker Pipeline plugin represents the baseline standard for containerized continuous integration. Understanding how workspaces are bind-mounted, how process UIDs are mapped, and how sidecars are networked provides the conceptual bridge to large-scale container orchestration systems like Kubernetes.