The discrete element modelling of triaxial tests plays a critical role in unveiling fundamental properties of particulate materials, but the numerical implementation of a flexible membrane boundary for the testing still imposes problems. In this study, a robust algorithm was proposed to reproduce a flexible membrane boundary in triaxial testing. The equivalence of strain energy enables the particle-scale parameters representing the flexible membrane to be directly determined from the real geometric and material parameters of the membrane. Then the proposed flexible membrane boundary was implemented in the context of discrete element simulation of triaxial testing and was validated with laboratory experiments. Furthermore, comparisons of triaxial tests with flexible and rigid boundaries were performed from macro-scale to meso-scale. The results show that the boundary condition has limited influences on the stress-strain behaviour but a relatively large impact on the volumetric change, the failure mode, the distribution of contact forces, and the fabric evolution of particles in the specimen during triaxial testing.