title: How to get Container Id of Docker in Jenkins
body: <p>I am using <a href="https://wiki.jenkins-ci.org/display/JENKINS/CloudBees+Docker+Custom+Build+Environment+Plugin" rel="nofollow noreferrer">Docker Custom Build Environment Plugin</a> to build my project inside <a href="https://github.com/jpetazzo/dind" rel="nofollow noreferrer">&quot;jpetazzo/dind&quot;</a> docker image. After building, in console output it shows:</p>
  <blockquote>
  <p>Docker container 212ad049dfdf8b7180b8c9b185ddfc586b301174414c40969994f7b3e64f68bc started to host the build</p>
  <p>$ docker exec --tty 212ad049dfdf8b7180b8c9b185ddfc586b301174414c40969994f7b3e64f68bc env</p>
  <p>[workspace] $ docker exec --tty --user 122:docker 4aea29fff86ba4e50dbcc7387f4f23c55ff3661322fb430a099435e905d6eeef env BUILD_DISPLAY_NAME=#73</p>
  </blockquote>
  <p>Here Docker Container which got started has container id <code>212ad049dfdf8b7180b8c9b185ddfc586b301174414c40969994f7b3e64f68bc </code>.
  Now further I want to execute some command on &quot;Execute shell&quot; part in &quot;Build&quot; option in Jenkins, there I want to use this Container Id. I tried using <code>${BUILD_CONTAINER_ID}</code> as mentioned in the plugin page. But that does't work.</p>