We study a free boundary problem modelling the motion of a piston in a viscous gas. The gas-piston system fills a cylinder with fixed extremities, which possibly allow gas from the exterior to penetrate inside the cylinder. The gas is modeled by the 1D compressible Navier-Stokes system and the piston motion is described by the second Newton's law. We prove the existence and uniqueness of global in time strong solutions. The main novelty brought in by our results is that they include the case on nonhomogeneous boundary conditions which, as far as we know, have not been studied in this context. Moreover, even for homogeneous boundary conditions, our results require less regularity of the initial data than those obtained in previous works.