Gravity keeps the beer in the glass and the bubbles rise through it.
Now imagine that you have a globule of beer floating in a spacecraft in zero gravity. In microgravity, surface tension tends to be the driving force behind fluid behaviour. Once released from whatever container it was in, your blob of beer would just float there. However, if you opened a can of beer in orbit, you'd create a nifty little beer cannon that cover the wall with several globs of beer. Bubbles would still form in your beer globule, because the carbon dioxide would still come out of solution under room temperature and pressure, but they wouldn't move in any direction.