docker-rake-flow 0.0.4 → 0.0.5

Sign up to get free protection for your applications and to get access to all the features.
Files changed (4) hide show
  1. checksums.yaml +4 -4
  2. data/Rakefile.rb +1 -0
  3. data/lib/utils.rb +35 -0
  4. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: eece5d6e3e4cb2488e51b4441af387845d2d1d1c
4
- data.tar.gz: ce155b5f72c210a73e255ea544f34de84b4156dd
3
+ metadata.gz: cadb7093fd4fcf80cc28ac9fff1b9f2716c30027
4
+ data.tar.gz: e6d65bea0e481ad30e5f571485bc8b86ca1299c2
5
5
  SHA512:
6
- metadata.gz: 50d4ecfcbcb2d4221591a7ff5eea165d5a59f3c861bca8074eaaa29e298cefe76b90618fc843b2581942b3dbf586d2c4d1b5c1a0f10c91771cccb26acd0d6340
7
- data.tar.gz: 68bf5864d1b6f7bd4c867fdd0b4dbd1fc81f05d59f3b8a2a6d16153e7357a7ea7283c2d9e8d7e8416b39b13a1102b7ddfb2ba37007d35a5c461a3487d3ef20ed
6
+ metadata.gz: f5eac9ea90aa27bb5893610a7977392eeb43df2ec3c50ffb779ae5da6ad77ee1ba32ceff4f2a2e623766936a56c0c2452443c04d9e1b0785d0f39ba8ea4204cd
7
+ data.tar.gz: b2973782d53ad95ee091ab2c0dc2a2876efb3042eb9670a6d11d1d3dddf071f383673147535f31d9d1bd5ca2ca7a9442ca3e459015258839db9dc72140c55cc7
data/Rakefile.rb CHANGED
@@ -2,3 +2,4 @@ require 'docker-rake-flow'
2
2
 
3
3
  flow = DockerFlow::RakeBuilder.new 'Docker Rake Flow', 'vjftw/docker-flow'
4
4
 
5
+ DockerFlow::Utils.clean_images flow.repository
data/lib/utils.rb CHANGED
@@ -116,4 +116,39 @@ class DockerFlow::Utils
116
116
  container.stop
117
117
  container.delete
118
118
  end
119
+
120
+ def self.clean_images(repository)
121
+ puts "Cleaning up Docker"
122
+ # Clean exited containers
123
+ for container in Docker::Container.all(all: true, filters: { status: ["exited"] }.to_json)
124
+ puts container.id
125
+ container.stop
126
+ container.delete(:force => true)
127
+ end
128
+
129
+ # Remove dangling images
130
+ for image in Docker::Image.all(all: true, filters: { dangling: ["true"] }.to_json)
131
+ puts image.id
132
+ begin
133
+ image.remove(:force => true)
134
+ rescue Docker::Error::NotFoundError
135
+ # Image already removed
136
+ end
137
+ end
138
+
139
+ # Clean tagged images
140
+ for image in Docker::Image.all
141
+ # puts image.info["RepoTags"]
142
+ for repoTag in image.info["RepoTags"]
143
+ if repoTag.include? repository
144
+ puts repoTag
145
+ begin
146
+ image.remove(:force => true)
147
+ rescue Docker::Error::NotFoundError
148
+ # Image already removed
149
+ end
150
+ end
151
+ end
152
+ end
153
+ end
119
154
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: docker-rake-flow
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.4
4
+ version: 0.0.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - VJ Patel
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-03-28 00:00:00.000000000 Z
11
+ date: 2016-04-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: docker-api