Gloucestershire reached 253-6 with four balls to spare after Cockbain shared a stand of 172 with Benny Howell (81).
Lukas Carey was Glamorgan's best bowler with four for 38.
Glamorgan made 252-9 thanks to openers Jacques Rudolph (60) and David Lloyd (49). But Glamorgan lost seamer Ruaidhri Smith to a leg injury suffered while bowling only his second over.
Both teams now play their opening first-class friendlies against student opposition, starting on Tuesday 28 March. Glamorgan host Cardiff MCCU while Gloucestershire face Durham MCCU in Bristol.

Swansea, two points adrift of safety, have beaten United four times in the last three years including two of their last three games at Old Trafford.
"We need to believe we can go up there and win because we've done it previously and it's not impossible," Britton told BBC Wales Sport.
"We can take confidence from that."
Britton, 34, played in Swansea's 2-1 FA Cup third round win in January 2014.
And on the opening day of the following 2014-15 season Swansea won by the same scoreline in what was Louis van Gaal's first competitive game as United boss.
"The record for ourselves isn't too bad," Britton said.
"It's a stadium that's been a fortress for Man United for many, many years but we've won twice up there.
"They're on a very good run under Jose Mourinho and are very tough to beat.
"They've got a few injuries which won't have helped them and a game on Thursday against Manchester City.
"They've got a busy period so we need to try and take advantage of that if we can."
Britton, whose appearance in last Saturday's win over Stoke City was his first game since December, admits this season has been Swansea's toughest yet in the Premier League.
Swansea, promoted in 2011, have had three managers during a campaign which has seen them in or around the relegation zone for most of the season.
"We've had situations where we've flirted with relegation and never been in the bottom three," Britton said.
"When Michael Laudrup got the sack [in 2014] there was a situation where we were on the verge of being dragged in but never did get dragged into the relegation battle.
"But this year, from very early on, we've been involved so without doubt this has been the toughest season we've had in the Premier League.
"It's been a difficult year for everyone."
Swansea beat Stoke 2-0 on Saturday to end a six-match winless run.
Media playback is not supported on this device
But Hull City's victory over Watford kept the Swans in the relegation zone, still two points adrift of the Tigers and safety.
Britton believes the battle to stay in the Premier League could go down to the final day of the season on 21 May when they host West Brom.
"It's very, very tight but we can take a lot of heart from the performance at the weekend against Stoke, not just the win but the way we played," Britton said.
"The previous five or six games we had dropped below the standard that had been set when Paul first came in.
"But hopefully there's a belief back in the changing room after the weekend and we need to take that into the last four games.
"As players you don't want relegation on your CV's. You don't want to be involved with that because when you get relegated it's a failure."
Gloucestershire beat Glamorgan by four wickets in their pre-season friendly thanks to Ian Cockbain's 125 not out.
[NEXT_CONCEPT]
Midfielder Leon Britton says Swansea City can take confidence from previous wins over Manchester United ahead of Sunday's Premier League game.