title: How to get the container Id of the running container using docker-java?
body: <p>I am running a container with name tag which allows me to identify it.In docker-java,it requires container id for most of the operations and i do not know how to get that using docker-java.Can anyone help me how to get the container Id for the running container?</p>
  
  <p>For example:</p>
  
  <blockquote>
    <p>docker ps</p>
  </blockquote>
  
  <pre><code>    CONTAINER ID        IMAGE               COMMAND                  CREATED             STATUS              PORTS               NAMES
  8945dcd6195b        e7a064b1705a        "java '-Duser.time..."   4 days ago          Up 20 seconds                           runDataMock
  </code></pre>
  
  <blockquote>
    <p>I am looking for a way by which i could get the ContainerId using the ContainerNames.</p>
  </blockquote>
  
  <p>NOTE: I am aware of the below method which creates a new container and picks the id.
   dockerClient.createContainerCmd(imageName).exec().getId()</p>