How to loop through all the attached images in a post, and get their url one by one

Put this in the template file at the beginning or in functions.php file:

function get_images_attachment_url()
{
  global $post; 
  $images_urls = array();

  $images_objects = get_attached_media( 'image', $post->ID );

  foreach ($images_objects as $image_object) {
    $images_urls[] = wp_get_attachment_url ($image_object->ID);
  } 
  return $images_urls;
}

When you need to call them use foreach after calling the function get_images_attachment_url():

$my_images_urls = get_images_attachment_url();
foreach ($my_images_urls as $url) {
?>
  <div style="background-image: url('<?php echo $url  ?>')"></div>
<?php
}