Docker-java: How can i get the ContainerId for a running container using Container name !

Created on 17 Apr 2017  路  1Comment  路  Source: docker-java/docker-java

I am looking for method/way to perform the opertion like the below one

public String getContainerIdUsingName(String containerName) { try{ Process p = Runtime.getRuntime().exec("docker ps -aqf \"name="+containerName+"\""); BufferedReader stdInput = new BufferedReader(new InputStreamReader(p.getInputStream())); return stdInput.readLine(); }catch (Exception exp){ exp.printStackTrace(); } return null; }

typquestion

Most helpful comment

@RajAsapu you can use InspectContainer command. Please see InspectContainerCmdImplTest for example usage. Remember to pass the container name instead of id - they both can be used here as described in the docs.

>All comments

@RajAsapu you can use InspectContainer command. Please see InspectContainerCmdImplTest for example usage. Remember to pass the container name instead of id - they both can be used here as described in the docs.

Was this page helpful?
0 / 5 - 0 ratings