garethr-docker icon indicating copy to clipboard operation
garethr-docker copied to clipboard

Support purge for Docker::Run

Open jcrsilva opened this issue 7 years ago • 4 comments

Feature request:

It would be nice if we had the option (in the main class configurations) to allow for purging of unmanaged containers and services

Right now if we remove a 'docker run' from the code, the container just keeps living in the machine forever

jcrsilva avatar May 24 '17 11:05 jcrsilva

There is (undocumented though) option to delete the container after running for docker::run here https://github.com/garethr/garethr-docker/blob/master/manifests/run.pp#L107 .

gdubicki avatar Jun 13 '17 12:06 gdubicki

@gdubicki issue is with the service files installed under systemd/init. If you remove a docker::run, those files are still in the system, and so the init system keeps bringing the containers up

jcrsilva avatar Jun 14 '17 14:06 jcrsilva

Oh, ok. Then there is another undocumented :), but standard, parameter - ensure - which you can use to delete the service. See the code: https://github.com/garethr/garethr-docker/blob/master/manifests/run.pp#L306

gdubicki avatar Jun 14 '17 15:06 gdubicki

Example:

docker::run { 'helloworld':
  ensure  => absent,
  image   => 'base',
  command => '/bin/sh -c "while true; do echo hello world; sleep 1; done"',
}

gdubicki avatar Jun 14 '17 15:06 gdubicki