David Cook Gray was born on November 29, 1842, in Pennsylvania to John and Maria Gray. His father was a farmer. The family lived in Hayfield, Pennsylvania, until the 1850s, when they moved to Waterford, Pennsylvania. By 1860, he was working as a laborer.
He enlisted in the Union army on August 26, 1861, and he mustered in as a private in Company E of the 83rd Pennsylvania Infantry. The regiment took part in the Seven Days’ Battles, the Second Battle of Manassas, the Battle of Antietam, the Battle of Fredericksburg, the Battle of Chancellorsville, the Battle of Gettysburg, the Overland Campaign, the siege of Petersburg, and the Appomattox campaign. He was promoted to corporal in December 1863 and to sergeant in March 1865. He mustered out on June 28, 1865.
He returned to Waterford after the war, and he worked as a tanner. He lived with his sister Margaret until at least 1880. He applied for a federal pension in October 1891 and eventually received one. He married Mary Smith in the early 1900s. He died of “cancer of [the] face” in Waterford on July 3, 1922.