title: Docker container rebuild inside of a project
body: <p>I have a project with the following structure:</p>
  <ul>
  <li><p>docker/Dockerfile</p>
  </li>
  <li><p>linux/*.xz (kernel sources)</p>
  </li>
  <li><p>*.sh</p>
  </li>
  <li><p>Jenkinsfile</p>
  </li>
  </ul>
  <p>Basically this pipeline is building a linux kernel inside of a docker container.</p>
  <p>We are using bitbucket in combination with jenkins and artifactory for CI/CD.</p>
  <p>Currently the building of the docker image is manual: a developr builds it locally and pushes it to artifactory.</p>
  <p>The pipeline is only pulling prebuilt docker images for execution.</p>
  <p>As this manual interaction is annoying this should be automated.</p>
  <p>Typical scenario could look like this: a developer changes the Dockerfile and some other ressource.</p>
  <p>This requires us to first rebuild the container, push it to artifactory and afterwards start the build.</p>
  <p>Is there a straightforward way to do this using the mentioned technologies?</p>
  <p>My approach would be (which is mainly a own implementation) to tag docker images based on their git revision.</p>
  <p>When the above mentioned pipeline starts it queries the git-rev of the Dockerfile of the last change and tries to pull the</p>
  <p>container. If this is possible - fine. Otherwise run a 'docker build' and push the new container. Afterwards run the kernel build inside.</p>
  <p>Is this a proper way to do that?</p>