title: Deploy docker container from external registry to Heroku
body: <p>I got project repository hosted on gitlab. I am using gitlab-ci to build docker container from my project. What I would like to achieve is deploying that container to heroku.</p>
  
  <p>I was trying to follow solution from this question: <a href="https://stackoverflow.com/questions/39011705/how-to-build-test-and-deploy-using-jhipster-docker-gitlab-and-heroku">How to build, test and deploy using Jhipster, Docker, Gitlab and Heroku</a></p>
  
  <p>Here is how my <code>.gitlab-ci.yaml</code> looks like:</p>
  
  <pre><code>stages:
   - build
   - package
   - deploy
  
  build_npm:
    image: node:latest
    stage: build
    script:
    - npm install
    - npm run build:prod
    artifacts:
      paths:
        - dist/
  
  build_image:
    image: docker:latest
    services:
    - docker:dind
    stage: package
    script:
      - docker login -u gitlab-ci-token -p $CI_BUILD_TOKEN registry.gitlab.com
      - docker build -t registry.gitlab.com/maciejsobala/myApp .
      - docker push registry.gitlab.com/maciejsobala/myApp:latest
  
  
  deploy_to_heroku:
    stage: deploy
    services:
    - docker:dind
    script:
      - gem install dpl
      - docker run registry.gitlab.com/maciejsobala/myApp:latest
      - dpl --provider=heroku --app= myApp --api-key=$HEROKU_API_KEY
  </code></pre>
  
  <p>What I am trying to achieve is, have 3 stages:</p>
  
  <ul>
  <li>build: at this moment, compile only npm project (in the future, I
  want to add some <code>jar</code> here) </li>
  <li>package: create and push to registry docker image. </li>
  <li>deploy: install docker image on heroku.</li>
  </ul>
  
  <p>I am running into issues with the last stage (<code>deploy</code>). To be honest I am not really sure, what should be done here.</p>
  
  <p>I tried to use dpl, regarding to this tutorial: <a href="https://docs.gitlab.com/ce/ci/examples/test-and-deploy-ruby-application-to-heroku.html" rel="noreferrer">https://docs.gitlab.com/ce/ci/examples/test-and-deploy-ruby-application-to-heroku.html</a> </p>
  
  <p>Unfornatelly I am running into issues when trying to run docker image</p>
  
  <pre><code>$ docker run registry.gitlab.com/maciejsobala/myApp:latest
  /bin/bash: line 49: docker: command not found
  </code></pre>
  
  <p>I am completely blind here. I would really appreciate any solutions, links to articles/tutorials etc.</p>