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-dockerVerified import paths — ran on the pinned version, not inferred.
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.
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.
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.
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.
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.
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.
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.
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.
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`.
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' }`.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.