The container can hold 12 gallons.
Let's say the container can hold x gallons of water.
Initially, the container was 1/2 full, so it contained (1/2)x gallons of water. After pouring out 2 gallons of water, the container was 1/3 full, so it contained (1/3)x gallons of water.
We can set up an equation to solve for x:
(1/2)x - 2 = (1/3)x
Multiplying both sides by 6 (the least common multiple of 2 and 3) gives:
3x - 12 = 2x
Simplifying this equation gives:
x = 12
Therefore, the container can hold 12 gallons of water.