How bacteria communicate and use bioluminescence:
It is known as Quorum sensing. The bacteria that do this constantly send out a specific signal no matter where they are. When a bacterium receives a signal from a different bacterium it begins to send out even more of its own signal. Once the signal binds with the receptor on the bacteria, certain parts of the bacteria's genetic code are expressed or repressed. Some of the genes affected are those that produce bioluminescence. As a result, all the bacteria in the colony behave identically; the colony behaves as an organism rather than a group of individuals.Different stimuli change the signal which is sent out. The size of the bacteria colony is an example of something that would change the signal to cause a bacteria to bioluminescent. For this reason, bioluminescent bacteria only glow when the colony population size is above a certain amount.They evolved to do so because it is inefficient for bacteria to glow when they are alone. Bacteria that live outside of an organism glow to attract the predator of a predator; if there very few bacteria, then they will not create enough of a distraction to make a difference. Therefore it is better if they do not glow when they are alone. When they are in a symbiotic relationship with a multicellular organism beneficial if they glow . The fact that they glow makes them a good tool for the organism; therefore the organism cares for them and enables them to reproduce. It is also believed that some bacteria use bioluminescence to communicate with each other. In this case, the glowing of the bacteria is used as a signal.

http://en.wikipedia.org/wiki/Quorum_sensing
http://www.ncbi.nlm.nih.gov/pubmed/11544353
http://www.ncbi.nlm.nih.gov/pubmed/10607620?ordinalpos=1&itool=EntrezSystem2.PEntrez.Pubmed.Pubmed_ResultsPanel.Pubmed_DiscoveryPanel.Pubmed_Discovery_RA&linkpos=1&log$=relatedreviews&logdbfrom=pubmed
http://departments.kings.edu/biology/lux/luxbiolum.html