We present the full thermodynamics of an interacting fluid confined by an arbitrary external potential. We show that for each confining potential, there emerge "generalized" volume and pressure variables V and P , that replace the usual volume and hydrostatic pressure of a uniform system. This scheme is validated with the derivation of the virial expansion of the grand potential. We discuss how this approach yields experimentally amenable procedures to find the equation of state of the fluid, P=P(VN,T) with N the number of atoms, as well as its heat capacity at constant generalized volume C_{V}=C_{V}(V,N,T) . With these two functions, all the thermodynamics properties of the system may be found. As specific examples we study weakly interacting Bose gases trapped by harmonic and by linear quadrupolar potentials within the Hartree-Fock approximation. We claim that this route provides an additional and useful tool to analyze both the thermodynamic variables of an ultracold trapped gas as well as its elementary excitations.