Most growing vegetables need a minimum of 6 hours of sunlight each day. That would be the first advantage of container gardening: you can move your plants to locations where they'll receive the most sun, if your yard is mostly shady.
Another advantage of container gardening is the ability to control your plants' moisture. If you're experiencing a summer that's particularly rainy, your plants won't get waterlogged if you just move them under cover. If your summer is unusually dry, you can keep your containers in a location that's convenient for reaching with a garden hose or pitchers of water.
Many vegetable plants will grow with 3-6 hours of sun per day. If you're trying to make the most of your space and your light isn't ideal, try growing salad greens, broccoli, cauliflower, peas, beets, brussels sprouts, radishes, beets, Swiss chard, and leafy greens like collards and spinach. Make sure your container and soil are deep enough to provide the recommended space for the roots to grow.
If you grow plants in containers, like pots, growing bags, windowsill boxes or even decorative pails, make sure you have adequate drainage. The best way to ensure your roots don't get waterlogged is to drill holes in the bottoms of the containers to allow excess water to drain out. Rocks placed in the bottom, before you fill with soil, will help the water drain without the soil washing out. It's also important to use a potting mix that drains well.
Plants in pots tend to dry out more quickly than those in the ground, so keep a close watch on the soil's water content and if the plant starts to wilt, it's probably time to water. Many edible plants now come in bush varieties, for smaller, more compact plants. These are ideal for porch or patio garden spaces.
Since potted vegetable plants will not have the benefit of all the nutrients in the ground, if their roots were free to grow in a garden plot, you'll also want to start with rich, composted soil and then regularly feed a high quality vegetable plant food, according to package directions.
A big advantage of container gardens is that pots can be placed where burrowing pests and other wildlife can't get to them.
Herbs do especially well in containers. In fact, some growers will only grow mint varieties in pots, since they are aggressive spreaders and will take over whatever space they can. Potted herbs can be grown in full sun outdoors, then at the end of the warm weather season can be brought inside and kept in a sunny windowsill to be fresh snipped for meal preparation for months past summer's end.
If you mix herbs in a container, plant the tallest ones in the back with shorter ones in front, so they're not hidden from sunlight. Container herb gardens are attractive and easy to grow, and they are a fun way to get children interested in gardening.