Grow onions in containers by planting onion bulbs or sets in a container with well-drained potting soil or by planting green onion seeds in a compost-filled container. The pots or containers need to contain drainage holes and be between 9 and 12 inches tall.
To grow yellow, white or red onions, fill a container with well-drained potting mix, or make some by combining soil, peat moss and vermiculite. Water the soil, and then place the bulbs, pointed ends up, in 1-inch deep holes with the holes spaced at least 3 inches apart. Put the container in an area with direct sunlight exposure, and water them regularly. Feed the onions an even-ratio water-soluble fertilizer every two weeks after they're planted. Dig up the onions once the tops grow 6 inches tall and turn brown.
Grow green onions by adding a layer of pebbles to the bottom of an 18-inch container and filling it with multipurpose compost. After watering the potting mix, add more compost until it nearly reaches the rim of the container. Till the compost into 1-inch deep rows, and sow the green onion seed. Water the seed regularly, and place the containers in direct sunlight for six hours. Once the plants grow to 4 inches in height, thin them out, and harvest them once the stems reach 6 inches.