Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docker::run and docker::exec lack refreshonly capability #687

Open
serverbiz opened this issue May 17, 2017 · 0 comments
Open

docker::run and docker::exec lack refreshonly capability #687

serverbiz opened this issue May 17, 2017 · 0 comments

Comments

@serverbiz
Copy link

Regular puppet exec has a refreshonly property which is very useful for using notify/subscribe to trigger the execution of commands that do not need to be executed on every puppet run. The best example is of such an event is a database upgrade. If we move the application into containers, we need a way to execute these same commands inside a container. The module currently doesn't seem to support that in an easy way.

Problem 1: docker::exec does not have a set-able refreshonly parameter

Adding a refreshonly parameter to docker:exec and the exec inside this define would be a useful addition.

Problem 2: docker::run does not support running a short-term foreground container

Unfortunately docker::exec would not over all use cases. It requires a container to already be running. In the case of my database migration example you would want to run this command before starting the service containers. So we need a way for docker::run to start a container, run the command and then automatically remove the container upon termination.

Doing this would require a few things:

  1. Adding a Boolean parameter like refreshonly = false to docker::run.
  2. Setting refreshonly=true would need to overrule $docker_run_flags array values resulting in --detach=false --rm=true. Note that the docker_run_flags parser does not yet support --rm.
  3. Extending the existing exec "run ${title} with docker" with a refreshonly => $refreshonly parameter. Using the existing exec is perfect to support this since, like the restart policy code, a one-time command execution container does not need an init script.

This would be a great enhancement. Only requires adding a parameter, extending the docker_run_flags parser and (changing) some if-statements.

electrofelix added a commit to electrofelix/garethr-docker that referenced this issue Jun 9, 2017
Allow for the refreshonly flag to be passed through to the underlying
exec resource.

This allows for Docker::Exec resources to be defined to only run when
notified, which allows for construction of manifests that can check
whether updated configuration made available to running containers
(provided they are using directory mount binds) are valid before
triggering a service restart.

Use case for this is to test generated nginx configuration for the
running nginx container using a Docker::Exec call that is notified by
the file resource and in turn will notify the service resource to
restart.

Partial fix for garethr#687
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

No branches or pull requests

1 participant