Yes, almost all ants can walk on vertical glass, or even upside down, without problem. To prevent escape, glass must be covered by some slippery grease. Teflon (PTFE) works very well.
Or with a teflon grease I told about. I can keep my formicariums always open thanks to it, this way I have no problems with ventilation and so no mold or ugly smells.