#23 inventory: Use 'docker rm' when cleaning up
Merged 6 years ago by merlinm. Opened 6 years ago by stefw.
stefw/standard-test-roles docker-kill-rm  into  master

@@ -61,7 +61,7 @@ 

  

      # And launch the actual container

      cmd = [

-         "/usr/bin/docker", "run", "--rm", "--detach", "--cidfile={0}".format(cidfile),

+         "/usr/bin/docker", "run", "--detach", "--cidfile={0}".format(cidfile),

          "--entrypoint=/bin/sh", image, "-c", "sleep 1000000"

      ]

  
@@ -127,7 +127,8 @@ 

  

      # Kill the container

      try:

-         subprocess.call(["/usr/bin/docker", "kill", name ])

+         subprocess.call(["/usr/bin/docker", "kill", name ], stdout=null)

+         subprocess.call(["/usr/bin/docker", "rm", "-f", name ], stdout=null)

      except OSError:

          pass

  

Certain older versions of docker do not like specifying both
--detach and --rm together on the run command line. So separate
out this step during cleanup.

This is a nice improvement that now allows the docker inventory script to also work on Fedora 25 in addition to F26.

Looks good and works for me.

Pull-Request has been merged by merlinm

6 years ago
Metadata