The Union Pacific Barrel was most likely used for bearing oil back in the days before we had sealed bearings AKA "journals" on the rail cars a worker called a Carman (we still have them) would walk the train lifting doors on the truck frame where the axle fit's under the truck and check the oil level and fill as needed.
I still have one of those barrel's down at my yard it has some oil left in it I would guess they were also used for any other lubricant needed such as motor oil, governor oil etc..
Here are some of the cans we used for these types of oil,
This was used to fill the journals
This was used for smaller areas inside the locomotive,