A method for producing a container comprising a sleeve-like main portion and an end piece attached to said main portion, said method comprising the steps of: - advancing, along a given path and by conveying means, at least one forming member having an axis transversal to said path, and delimited by a top surface and by a lateral surface extending around said axis; - feeding said end piece on said top surface of said forming member; - wrapping a sheet of packaging material around said lateral surface of said forming member such that the opposite side edges (4a, 4b) of the sheet parallel to said axis overlap one another; - joining said overlapped edges (4a, 4b) of said sheet by a longitudinal seal so as to form the sleeve-like main portion of the container; and - joining a peripheral edge of said end piece to an upper end of said sleeve-like main portion by a transversal seal extending around said axis; wherein said forming member receives said end piece and said sheet in a first position, and, after said joining steps, said forming member is axially displaced in a second position, in which it is extracted from said sleeve-like main portion so allowing release of the formed container; characterized in that, during said step of wrapping, the forming member is rotated about its axis; in that said forming member has a side wall provided with a plurality of through holes connected to a pneumatic suction device; in that said sheet is retained on said lateral surface of said forming member by suction; in that said forming member is supported, in a sliding and rotating manner with respect to said axis, by a supporting mount carried by said conveying means; and in that, in said second position, said forming member is completely retracted within said supporting mount, so that said top surface is substantially flush with a top surface of the supporting mount. - advancing, along a given path and by conveying means, at least one forming member having an axis transversal to said path, and delimited by a top surface and by a lateral surface extending around said axis; - feeding said end piece on said top surface of said forming member; - wrapping a sheet of packaging material around said lateral surface of said forming member such that the opposite side edges (4a, 4b) of the sheet parallel to said axis overlap one another; - joining said overlapped edges (4a, 4b) of said sheet by a longitudinal seal so as to form the sleeve-like main portion of the container; and - joining a peripheral edge of said end piece to an upper end of said sleeve-like main portion by a transversal seal extending around said axis; wherein said forming member receives said end piece and said sheet in a first position, and, after said joining steps, said forming member is axially displaced in a second position, in which it is extracted from said sleeve-like main portion so allowing release of the formed container; characterized in that, during said step of wrapping, the forming member is rotated about its axis; in that said forming member has a side wall provided with a plurality of through holes connected to a pneumatic suction device; in that said sheet is retained on said lateral surface of said forming member by suction; in that said forming member is supported, in a sliding and rotating manner with respect to said axis, by a supporting mount carried by said conveying means; and in that, in said second position, said forming member is completely retracted within said supporting mount, so that said top surface is substantially flush with a top surface of the supporting mount.