There are more exact formulas, I understand, but these are good for approximation:
Circumferential ("hoop") stress: S = PDi/2T (P = pressure, Di = inner diameter, T = pipe wall thickness) [Barlow's formula].
Longitudinal (cross-sectional) stress: S = (π/4) Di2 ÷ π(Do2 - Di2). (Do = outer diameter.)
Usually the circumferential stress governs, but there might be some combinations in which the longitudinal stress is the greater. You should check both.
Pressure vessels use a safety factor of 4 (ultimate versus imposed tensile); I forget what is standard for hydraulic components.
__________________
In vino veritas; in cervisia carmen; in aqua E. coli.
As stated above, do a force balance along a plane that bisects the cylinder along a diameter.
Repeat the process for the end caps, in the plane of the end caps.
__________________
"Did you get my e-mail?" - "The biggest problem in communication is the illusion that it has taken place" - George Bernard Shaw, 1856
You should consider 2 situations:
-piston not in contact with end cap = no axial force on tube
-piston in end position full force on end cap.
The tube is in the 1st situation loaded in radial direction by the pressure and lies under a plane stress, in the second the stress is axial as well so that at same time on a point at the internal surface (most loaded) a triaxial stress appears.
Since the 3 stresses appear at same time the correct approach is to consider the von Mises equivalent stress as value for design. σvM=P*(1+2*(β^4+1))^0.5/(β^2-1).
Β=Do/Di
In hydraulic circuits pressure peaks can reach 2x nominal pressure. Computed stress value should be then less Re/2 where Re is the elastic limit of the used material.
For higher pressure it is also important to check the diameter increase since the gap if too big could lead to seal extrusion:
e=p*Di*((β^2+1)/(β^2-1))/(2*E) without axial force and
e=p*Di*((1+ν)*β^2+1-2*ν)/(2*E) in the end position.
ν= Poisson's coefficient 0.3 and E young modulus about 1.9E5 to 2.1E5 N/mm^² for steels.
Obtained values have to be added to maximal gap from manufacturing tolerances and it should be less maximal gap allowed for the seals used.