That's because both H2O molecules and 'glass molecules', more precisely an enormous lattice of silica oxide, are polar. The surface of the glass consists of unsaturated oxygen atoms which can form H- bonding with the water molecules, giving that U shape you are seeing when you put water in a narrow cylinder.