✦ For everyone, free.

Practical knowledge for real and everyday life

Home

1.2.3.4 Pipeline Execution Portability

A focused guide to Pipeline Execution Portability, connecting core concepts with practical Docker and container operations.

Pipeline execution portability is the ability to run the same Docker container, with the same behavior, inside a CI/CD pipeline as it would have on a developer's machine or in production, so that pipeline stages can be trusted as a faithful test of how the application actually behaves.

Why Pipelines Benefit From Portability

A CI/CD pipeline typically runs on infrastructure entirely separate from where developers write code and from where the application is ultimately deployed. Without containerization, a pipeline runner needs its own manually maintained set of installed tools matching what the application expects, which can drift out of sync with what developers actually use locally.

job:
  image: python:3.12-slim
  script:
    - pip install -r requirements.txt
    - pytest

Specifying the exact image a pipeline step runs in removes the need for the pipeline infrastructure to be manually kept in sync with the application's requirements — the requirement is declared per job, in the same file that defines the pipeline itself.

Running the Actual Application Image in the Pipeline

Pipeline execution portability extends beyond running tools inside a generic image — pipelines can build the application's own image and run tests inside a container instantiated from it, which is the most direct way to ensure that what is tested is what will be deployed.

docker build -t myapp:$CI_COMMIT_SHA .
docker run --rm myapp:$CI_COMMIT_SHA pytest
Portability Across Different CI Providers

Because the unit of execution is a standard container image rather than a CI-provider-specific configuration, the same Dockerfile and test commands can be reused across different CI systems with minimal adaptation, since each CI system is simply responsible for invoking docker build and docker run in its own way.

docker build -t myapp:test . && docker run --rm myapp:test pytest
Caching Across Pipeline Runs

Pipeline execution portability is often paired with layer caching, so that pipeline runs do not pay the full cost of rebuilding an image from scratch every time, while still guaranteeing the same reproducible build process.

docker build --cache-from myapp:cache -t myapp:test .
Why This Matters for Trust in Pipeline Results

When the pipeline executes the same image that would later be deployed, a passing pipeline run is direct evidence that the deployed artifact behaves correctly, rather than indirect evidence based on a separately assembled pipeline environment that might not match production.