I assume that by specifying "walls" you mean "walls without a roof." (If not, ignore everything I say below!)
The answer is "yes," but it may be less useful than you think. Basically, when you have a gas surrounding a planet, the gas has a characteristic decrease in density with altitude. The rate at which density decreases depends on the molecular weight of the gas (higher MW gasses thin out more quickly with altitude) and temperature (cooler gasses thin out more quickly with altitude). But there is no altitude where the atmosphere is 100%-gone, and there's always a slow leakage into space.
In general, air pressure drops as the negative exponential of the height. On Earth, pressure halves every 18,000 feet (more or less). On the Moon with its lower gravity, the halving distance would be around 100,000 feet (20 miles). As a consequence, the lunar atmosphere extends a lot further into space for any given density. (Which is partly why the Moon has so much more trouble holding onto it.)
The more massive the planet, the slower the leakage. If it wasn't for extraneous effects (solar wind, solar UV) the Earth's atmosphere would be essentially permanently trapped. The Moon's, not so much. If you magically gave the Moon an atmosphere resembling Earth's, it would lose it fairly quickly. (I can't find a number for this, but a couple of early-Moon scenarios show it losing a thick atmosphere in ca. 10 MYears.)
Here's the kicker: Walls, by themselves, don't do much to hold in an atmosphere unless they're tall enough that the air density at the top is low enough that leakage is tolerable. If you want an Earth-surface atmosphere at the lunar surface, to get to .001 atmosphere, you'd need to go up 10 "halving-heights" or 200 miles. Using a very simple model, I get the time in hours to halve the air pressure in an open tube on the Moon to be roughly h/(1400*p) where h is the tube's height in miles and p is the pressure at the top of the tube in atmospheres. (I made some linearizing assumptions, so there's probably at least a factor of two error in the formula, but probably less than a factor of ten.)
That says that a 200 mile tube (h=200, p=.001) would lose half its air in 150 hours. A 300 mile tube would lose half its air in 1700 hours. A 400 mile tube would lose half its air in 20,000 hours, and so forth. To get to 100 years, you need about 500 mile-high walls.
You might do better sticking with domes...