Skip to content

operations.docker: add extra parameters#1593

Merged
DonDebonair merged 3 commits intopyinfra-dev:3.xfrom
KalvadTech:operations-docker-container-new-options
Apr 19, 2026
Merged

operations.docker: add extra parameters#1593
DonDebonair merged 3 commits intopyinfra-dev:3.xfrom
KalvadTech:operations-docker-container-new-options

Conversation

@wowi42
Copy link
Copy Markdown
Collaborator

@wowi42 wowi42 commented Mar 10, 2026

add mount, privileged, hostname, entrypoint, user, cpus, memory and extra_args to container

  • Pull request is based on the default branch (3.x at this time)
  • Pull request includes tests for any new/updated operations/facts
  • Pull request includes documentation for any new/updated operations/facts
  • Tests pass (see scripts/dev-test.sh)
  • Type checking & code style passes (see scripts/dev-lint.sh)

Copy link
Copy Markdown
Member

@Fizzadar Fizzadar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice, thank you @wowi42!

@Fizzadar
Copy link
Copy Markdown
Member

Augh another PR also touched this op; there's some conflicts here @wowi42 (I don't have permission to fix)

Resolves conflicts in src/pyinfra/operations/docker.py and
src/pyinfra/operations/util/docker.py: this branch adds the
``mounts``, ``privileged``, ``hostname``, ``entrypoint``, ``user``,
``cpus``, ``memory`` and ``extra_args`` parameters to
``docker.container`` while 3.x independently added ``dns``. Both sets
of fields are kept and exposed:

- ``ContainerSpec`` grows both groups of fields (in addition to the
  existing ones) and ``container_create_args`` emits all the
  corresponding ``docker container create`` flags, with the ``--dns``
  entries rendered after the new branch-specific flags so existing
  fixtures match.
- ``docker.container`` grows both the new keyword arguments and the
  docstring bullets, forwarding everything through ``ContainerSpec``.
@wowi42
Copy link
Copy Markdown
Collaborator Author

wowi42 commented Apr 14, 2026

@Fizzadar just fixed the conflict

Comment thread src/pyinfra/operations/util/docker.py Outdated
if self.privileged:
args.append("--privileged")

if self.hostname:
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nitpick: why not explicitly use if self.hostname is not None, just like withg self.cpu? Same goes for the other params.

@DonDebonair DonDebonair merged commit b0fe38f into pyinfra-dev:3.x Apr 19, 2026
26 checks passed
@wowi42 wowi42 deleted the operations-docker-container-new-options branch April 20, 2026 19:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants