Laser light trapping in cavities in near-critical density plasmas is studied by two-dimensional particle-in-cell simulation. The laser ponderomotive force can create in the plasma a vacuum cavity bounded by a thin overcritical-density wall. The laser light is self-consistently trapped as a half-cycle electromagnetic wave in the form of an oscillon-caviton structure until it is slowly depleted through interaction with the cavity wall. When the near-critical density plasma contains a preformed cavity, laser light can become a standing wave in the latter. The trapped light is characterized as multi-peak structure. The overdense plasma wall around the self-generated and preformed cavities induced by the laser ponderomotive force is found to be crucial for pulse trapping. Once this wall forms, the trapped pulse can hardly penetrate.