How to automatically populate a gallery with images attached to posts of one category?

In form of a shortcode to render a default WordPress shortcode including all attachments of the given categories:

/**
 * Usage: [catgallery cat="4,5"]
 * Attribute: array of category IDs
 */

add_shortcode('catgallery', 'wpse_70989_cat_gallery_shortcode');

function wpse_70989_cat_gallery_shortcode($atts) 
{
    // $return = ''; // DEBUG: enable for debugging
    $arr = array();
    $cat_in = explode( ',', $atts['cat'] );
    $catposts = new WP_Query( array(
        'posts_per_page'    => -1
    ,   'category__in'      => $cat_in
    ) );

    foreach( $catposts->posts as $post)
    {

        // DEBUG: Enable the next line to print the post title
        // $return .= '<strong>' . $post->post_title . '</strong><br />';

        $args = array( 
            'post_type'     => 'attachment'
        ,   'numberposts'   => -1
        ,   'post_status'   => null
        ,   'post_parent'   => $post->ID 
        ); 
        $attachments = get_posts($args);

        if ($attachments) 
        {
            foreach ( $attachments as $attachment ) 
            {
                // DEBUG: Enable the next line to debug the attachement object
                // $return .= 'Attachment:<br /><pre>' . print_r($attachment, true) . '</pre><br />';
                $arr[] = $attachment->ID;
            }
        }

    }
    // DEBUG: Disable the next line if debugging 
    $return = do_shortcode( '' );
    return $return;
}

Read the documentation to fine tune the code to your specs.