After some rows the css float property have a strange behavior that i couldn't know its reason.
Take into account that I cannot add a div with a "clear" property between the rows because the html will be generated dynamically (php loop).
I think that in order to do that I should create a function in php that determines when to insert a clear div between the rows because sometimes there are 2 images per and other times 3.
But I prefer a CSS solution.
Here is the full code:
.row {
    width: 600px;
    text-align: center;
    margin: 0 auto;
}
.boxes{
    box-sizing: border-box;
    position: relative;
    min-height: 1px;
    height: auto;
    float: left;
    padding-left: 10px;
    padding-bottom: 10px;   
}
.box1 {
    width: 33.33333333333333%;
}
.box2 {
    width: 66.66666666666666%;
}
.box-inner {
    background-color: grey;
    width: 100%;
    height: 100%;
}
.img-responsive {
    display: block;
    max-width: 100%;
    height: auto;
}<html>
  <body>
    <div class="row">
      <div class="box1 boxes">
        <div class="box-inner">
          <img class="img-responsive" src="https://picsum.photos/390/244?random=1" alt="">
        </div>
      </div>
      <div class="box1 boxes">
        <div class="box-inner">
          <img class="img-responsive" src="https://picsum.photos/390/244?random=1" alt="">
        </div>
      </div>
      <div class="box1 boxes">
        <div class="box-inner">
          <img class="img-responsive" src="https://picsum.photos/390/244?random=1" alt="">
        </div>
      </div>
      <div class="box1 boxes">
        <div class="box-inner">
          <img class="img-responsive" src="https://picsum.photos/390/244?random=1" alt="">
        </div>
      </div>
      <div class="box2 boxes">
        <div class="box-inner">
          <img class="img-responsive" src="https://picsum.photos/770/238?random=1" alt="">
        </div>
      </div>
      <div class="box2 boxes">
        <div class="box-inner">
          <img class="img-responsive" src="https://picsum.photos/770/238?random=1" alt="">
        </div>
      </div>
      <div class="box1 boxes">
        <div class="box-inner">
          <img class="img-responsive" src="https://picsum.photos/390/244?random=1" alt="">
        </div>
      </div>
      <div class="box1 boxes">
        <div class="box-inner">
          <img class="img-responsive" src="https://picsum.photos/390/244?random=1" alt="">
        </div>
      </div>
      <div class="box1 boxes">
        <div class="box-inner">
          <img class="img-responsive" src="https://picsum.photos/390/244?random=1" alt="">
        </div>
      </div>
      <div class="box1 boxes">
        <div class="box-inner">
          <img class="img-responsive" src="https://picsum.photos/390/244?random=1" alt="">
        </div>
      </div>
    </div>
  </body>
</html> 
     
    