Question: I don't understand why $('selector').html() works differently from document.querySelectorAll when used inside a loop. I'm asking this question because I believe the answer might make me understand closures better.

Say I have a HTML file with an unordered list containing 3 empty list items.

```
<ul>
 <li></li>
 <li></li>
 <li></li>
</ul>

```

Next I want to insert some values inside the list items using a ascending loop and jQuery like so:

```
$(document).ready(function () {
  for (let i = 0; i < 3; i++) {
    $('ul li').html(i); /// Output: all list items are filled with 2
  }
})

```

All list items now contain "2" which is not what I expected. I was expecting 0, 1, 2.

Next I also tried the same thing in JS and the output was different

```
window.onload = function () {
  let list = document.querySelectorAll('ul li');

  for (let i = 0; i < 3; i++){
    list[i].innerHTML = i; //Output: 0 1 2
  }
}

```

In order to find a fix for the jQuery version on my code I checked the MDN section on closures and found this fix:

```
$(document).ready(function () {
  for (let i = 0; i < 3; i++) {
    $('ul li').html(foo(i)); /// output: 0 1 2
  }

  function foo(n) {
    return function bar(n) {
      return n;
    }
  }
})

```

Even if this works at the moment, I would like to know why does using the $().html() work differently from the plain JS example?

Answer: 
Did you have a `CMD` directive specified at the end of your Dockerfile? If not, that was likely causing the problem, which you then worked around by using `heroku.yml` and `heroku stack:set container`.

Heroku is unclear on this in their documentation. I was able to get my container to run locally without a `CMD` directive, likely as you were. But if you read Heroku docs [here](https://devcenter.heroku.com/articles/container-registry-and-runtime#dockerfile-commands-and-runtime) or [here](https://devcenter.heroku.com/articles/build-docker-images-heroku-yml#getting-started) you'll pick up that Heroku takes for granted that the Dockerfile will specify a `CMD` to run.

I had the same problem until I added the `CMD` directive at the end of my Dockerfile. I'm still working though what exactly I should put as my `CMD` directive but I no longer get the `No command specified for process type web` error.

Since you switched to using `heroku.yml` you were able to get around the `CMD` by using

```
run:
  web: dotnet Api.dll

```

Heroku docs [say](https://devcenter.heroku.com/articles/build-docker-images-heroku-yml#getting-started) "If you don’t include a `run` section, Heroku uses the `CMD` specified in the Dockerfile."
I figured out the reason after searching for hours.

Apparently if forgot to call 
`heroku stack:set container`. 

Now I'm able to deploy and release!