@@ -76,6 +76,13 @@ public class DockerClient {
76
76
@ Restricted (NoExternalUse .class )
77
77
public static int CLIENT_TIMEOUT = Integer .getInteger (DockerClient .class .getName () + ".CLIENT_TIMEOUT" , 180 ); // TODO 2.4+ SystemProperties
78
78
79
+ /**
80
+ * Skip removal of container after a container has been stopped.
81
+ */
82
+ @ SuppressFBWarnings (value ="MS_SHOULD_BE_FINAL" , justification ="mutable for scripts" )
83
+ @ Restricted (NoExternalUse .class )
84
+ public static boolean SKIP_RM_ON_STOP = Boolean .getBoolean (DockerClient .class .getName () + ".SKIP_RM_ON_STOP" );
85
+
79
86
// e.g. 2015-04-09T13:40:21.981801679Z
80
87
public static final String DOCKER_DATE_TIME_FORMAT = "yyyy-MM-dd'T'HH:mm:ss" ;
81
88
@@ -165,7 +172,8 @@ public List<String> listProcess(@Nonnull EnvVars launchEnv, @Nonnull String cont
165
172
* Stop a container.
166
173
*
167
174
* <p>
168
- * Also removes ({@link #rm(EnvVars, String)}) the container.
175
+ * Also removes ({@link #rm(EnvVars, String)}) the container if property
176
+ * SKIP_RM_ON_STOP is unset or equals false.
169
177
*
170
178
* @param launchEnv Docker client launch environment.
171
179
* @param containerId The container ID.
@@ -175,7 +183,9 @@ public void stop(@Nonnull EnvVars launchEnv, @Nonnull String containerId) throws
175
183
if (result .getStatus () != 0 ) {
176
184
throw new IOException (String .format ("Failed to kill container '%s'." , containerId ));
177
185
}
178
- rm (launchEnv , containerId );
186
+ if (!SKIP_RM_ON_STOP ) {
187
+ rm (launchEnv , containerId );
188
+ }
179
189
}
180
190
181
191
/**
0 commit comments