Registry / devops / pulumi-docker

pulumi-docker

JSON →
library5.0.0pypypi✓ verified 87d ago

Pulumi Docker is a Pulumi package for interacting with Docker in Pulumi programs, allowing users to define, deploy, and manage Docker containers, images, networks, and volumes using general-purpose programming languages. It is currently at version 4.11.2 and maintains an active release cadence with frequent minor updates, often incorporating bridge upgrades and GitHub Actions workflow improvements.

pip install pulumi-docker
INSTALL
IMPORT
SIG · PULUMI-DOCKER
P
pulumi-docker
devopspythonv5.0.0
Install
6.4s avg
Import
1470ms
Disk
81MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v5.0.0 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.103.920 runs
installs and imports cleanly · install 0.0s · import 1.813s · 89.6MB
glibc
py 3.103.920 runs
installs and imports cleanly · install 6.4s · import 1.127s · 75MB
81MB installed
● package 81MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

docker
import pulumi_docker as docker
RemoteImage
from pulumi_docker import RemoteImage
from pulumi_docker.remoteimage import RemoteImage
Resources are directly available under the `pulumi_docker` namespace or via `pulumi_docker.RemoteImage` rather than deeper module paths.
Container
from pulumi_docker import Container

This quickstart program pulls the `nginx:latest` Docker image and then creates a container, exposing port 8080 on the host mapped to port 80 internally in the container. It then exports the container ID and the external port. For private registries, uncomment and configure the `registry` arguments within `RemoteImage` using environment variables for sensitive credentials.

import pulumi import pulumi_docker as docker import os # Pull a remote Docker image (e.g., NGINX latest) nginx_image = docker.RemoteImage("nginx-image", name="nginx:latest" ) # Create a Docker container from the pulled image nginx_container = docker.Container("nginx-container", image=nginx_image.image_id, ports=[docker.ContainerPortArgs( internal=80, external=8080, )], # Example of setting environment variables for a private registry if needed # registry=docker.RegistryArgs( # server="your.private.registry", # username=os.environ.get('DOCKER_REGISTRY_USER', ''), # password=os.environ.get('DOCKER_REGISTRY_PASS', ''), # ) ) # Export the container ID and the external port pulumi.export("container_id", nginx_container.id) pulumi.export("external_port", 8080)
Debug
Known issues
breakingBreaking change in `v4.7.0`: The `RemoteImageBuild` resource's `buildArg` property was removed. Programs using this property will fail upon upgrade.
fix
Review your `RemoteImageBuild` configurations and update them to reflect the removal of `buildArg`. Consult the specific v4.7.0 release notes for alternatives or updated schema.
affects: >=4.7.0
breakingSignificant overhaul of the `docker.Image` resource in `v4.0.0`. This included breaking changes to its behavior, supporting types, and minor name changes. Existing programs using `docker.Image` might require code adjustments.
fix
Refer to the v4.0.0 release notes for a detailed migration guide. Update your Pulumi program code to align with the new `docker.Image` resource API and types.
affects: >=4.0.0
gotchaWhen configuring `registryAuth` for the Docker provider, passing `config_file` (e.g., `~/.docker/config.json`) may trigger a type checking warning (as of v4.6.1) that indicates it will become a hard error. This is a discrepancy between documentation and type definitions.
fix
While `config_file` is documented, consider using `configFileContent` to provide the content directly, or rely on `DOCKER_REGISTRY_USER` and `DOCKER_REGISTRY_PASS` environment variables, which have lower precedence but avoid this type-checking issue. Always check the latest provider documentation for the officially supported method.
affects: >=4.6.1
gotchaWhen using `pulumi-docker` with a remote Docker host, the remote daemon's default configuration might apply settings (e.g., log options) that are not explicitly defined in your Pulumi program. This can cause spurious diffs during `pulumi preview` or `pulumi up` on subsequent runs.
fix
Utilize Pulumi's `ignoreChanges` lifecycle meta-argument for attributes prone to such external modifications (e.g., `opts=pulumi.ResourceOptions(ignore_changes=['container.log_driver', 'container.log_opts'])`). Alternatively, ensure the Docker daemon on the remote host is configured precisely to avoid unexpected defaults.
affects: All versions
gotcha`docker build` operations within Pulumi programs, especially when using `cacheFrom: true` or specific credential helpers (like for Google Container Registry), can significantly slow down `pulumi preview` and `pulumi up`, even if all layers are cached locally.
fix
For performance-critical or frequently changing images, consider pre-building Docker images as part of an external CI/CD pipeline and then having Pulumi deploy these pre-built images from a container registry. If building within Pulumi, ensure Docker's build cache is effectively utilized and review builder configuration.
affects: All versions
gotchaWhile `pulumi-docker` supports building images, for production environments and complex applications, it's often recommended to separate concerns by using dedicated CI/CD pipelines for building and pushing Docker images. Pulumi should then consume these pre-built images from a container registry.
fix
Implement a CI/CD pipeline (e.g., GitHub Actions, GitLab CI) to handle `docker build`, testing, tagging, and pushing images to a registry. Your Pulumi program can then reference these images by their immutable tags or digests, enhancing modularity, reusability, and deployment speed.
affects: All versions
Errors
Common errors & fixes
failed to connect to any docker daemon
The Pulumi Docker provider cannot communicate with the Docker daemon because it is not running, not accessible, or the DOCKER_HOST environment variable is misconfigured.
fix
Ensure the Docker daemon is running and accessible (e.g., `sudo systemctl start docker` on Linux, or ensure Docker Desktop is running). Verify `DOCKER_HOST` environment variable is correctly set if using a remote or non-default Docker socket.
ModuleNotFoundError: No module named 'pulumi_docker'
The `pulumi_docker` Python package is not installed in the active Python environment where `pulumi up` is being executed, or the virtual environment is not correctly activated.
fix
Install the package using pip: `pip install pulumi_docker`. If using a virtual environment (like `venv` or `conda`), ensure it's activated before running `pip install` and `pulumi up`.
docker build -f Dockerfile . -t ... failed with error: exit status 1 / failed to read dockerfile: open ... Dockerfile: no such file or directory
The Docker daemon, invoked by Pulumi, cannot find the specified Dockerfile or the build context is incorrect, often due to Pulumi running from a different working directory than expected.
fix
Specify the `context` and `dockerfile` paths explicitly in your `docker.Image` resource definition, usually relative to your Pulumi program's root, for example: `build: { context: './app', dockerfile: './app/Dockerfile' }`.
Error: Cannot perform an interactive login from a non TTY device / docker login failed with error: exit status 1
This error occurs in non-interactive environments, such as CI/CD pipelines, when the Docker provider attempts an interactive login to a container registry that requires authentication without providing explicit credentials.
fix
Configure Docker registry authentication non-interactively within your Pulumi program, typically by providing `registry` credentials (username, password/token, server) to the `docker.Image` or `docker.RegistryImage` resource, or by ensuring appropriate environment variables are set for the Docker CLI.
Upgrade
Version history
5.0.0latest on PyPI · released Apr 21, 2026
Audit
Dependencies
pulumirequiredCore Pulumi SDK is required for any Pulumi provider.
Agent activity
27 hits · last 30 days
node
22
OpenAI (training)
1
Resources
pulumi-docker — pip install pulumi-docker · libregistry