@@ -293,6 +293,7 @@ public String whoAmI() throws IOException, InterruptedException {
293
293
*
294
294
* @return an optional string containing the <strong>container id</strong>, or <strong>absent</strong> if
295
295
* it isn't containerized.
296
+ * @see <a href="http://stackoverflow.com/a/25729598/12916">Discussion</a>
296
297
*/
297
298
public Optional <String > getContainerIdIfContainerized () throws IOException , InterruptedException {
298
299
final Pattern pattern = Pattern .compile (CGROUP_MATCHER_PATTERN );
@@ -321,15 +322,16 @@ public ContainerRecord getContainerRecord(@Nonnull EnvVars launchEnv, String con
321
322
}
322
323
323
324
/**
324
- * Inspect the volumes of a docker image/container.
325
+ * Inspect the mounts of a container.
326
+ * These might have been declared {@code VOLUME}s, or mounts defined via {@code --volume}.
325
327
* @param launchEnv Docker client launch environment.
326
- * @param objectId The image/ container ID.
327
- * @return a list of volumes of the docker image/ container.
328
+ * @param containerID The container ID.
329
+ * @return a list of filesystem paths inside the container
328
330
* @throws IOException Execution error. Also fails if cannot retrieve the requested field from the request
329
331
* @throws InterruptedException Interrupted
330
332
*/
331
- public List <String > getVolumes (@ Nonnull EnvVars launchEnv , String objectId ) throws IOException , InterruptedException {
332
- LaunchResult result = launch (launchEnv , true , "inspect" , "-f" , "{{range $index, $element := .Config.Volumes }}{{$index }}\n {{end}}" , objectId );
333
+ public List <String > getVolumes (@ Nonnull EnvVars launchEnv , String containerID ) throws IOException , InterruptedException {
334
+ LaunchResult result = launch (launchEnv , true , "inspect" , "-f" , "{{range .Mounts }}{{.Destination }}\n {{end}}" , containerID );
333
335
if (result .getStatus () != 0 ) {
334
336
return Collections .emptyList ();
335
337
}
0 commit comments