Skip to content

operations.docker: add support for custom command#1625

Merged
Fizzadar merged 4 commits intopyinfra-dev:3.xfrom
EricDriussi:3.x
Apr 25, 2026
Merged

operations.docker: add support for custom command#1625
Fizzadar merged 4 commits intopyinfra-dev:3.xfrom
EricDriussi:3.x

Conversation

@EricDriussi
Copy link
Copy Markdown
Contributor

  • 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)

Hi there! Noticed another thing missing from the docker container operation.
This adds support for custom commands to be run on container start.

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.

Hi @EricDriussi sorry for the delay - this looks great, a couple of minor tweaks to the arguments + fix for default / no argument.

Comment thread src/pyinfra/operations/util/docker.py Outdated
Comment thread src/pyinfra/operations/util/docker.py Outdated
Comment thread src/pyinfra/operations/docker.py Outdated
docker.container(
name="Run a custom command",
container="alpine",
command="sh -c 'echo Whatever you want",
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Suggested change
command="sh -c 'echo Whatever you want",
command="sh -c "echo Whatever you want",

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Looking at your suggestion I realized I forgot to close the inner quotes! Let me know if the update looks OK!

Comment thread src/pyinfra/operations/docker.py Outdated
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.

Looks good to me, thank you @EricDriussi!

@Fizzadar Fizzadar merged commit 3c1252f into pyinfra-dev:3.x Apr 25, 2026
27 checks passed
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.

2 participants