Back

Explore Courses Blog Tutorials Interview Questions
0 votes
2 views
in DevOps and Agile by (2.3k points)

I was looking to remove a few images. How can i achieve this using puppet code?

2 Answers

0 votes
by (41.4k points)
edited by

To remove an image, add the following code to the manifest file:

docker::image { 'base':

  ensure => 'absent'

}

docker::image { 'ubuntu':

  ensure    => 'absent',

  image_tag => 'precise'

}

This will act as a docker rm command.

If you are interested to learn DevOps, I would recommend this Intellipaat’s DevOps Training Course and fast-track your career.

0 votes
by (6.9k points)

First, make sure you have docker deployed using puppet in your prefered location. 

To pull a docker image :

create a <name of file>.pp file and inside it write :

docker::image { 'ubuntu':

  ensure    => 'present',

  image_tag => 'trusty'

}

type this command to run the file, it will pull the image you specified.

$ puppet apply pull_image.pp

To remove a docker image :

create a <name of file>.pp file and inside it write :

docker::image { 'ubuntu':

  ensure    => 'absent',

  image_tag => 'trusty'

}

type this command to run the file, it will remove the image you specified.

$ puppet apply rm_image.pp 

Hope this helps. 

Browse Categories

...