Most vegetables that can be grown outdoors will do well in containers. Pumpkins and cucumbers, both of which take considerable space, might not be great choices. But tomatoes, peas, peppers, carrots and many others will do just as well (sometimes better) in a container.
Selecting a container that is large enough for a full grown, harvest-ready plant is essential. Select soil that is free from weeds and be sure to add adequate fertilizer before you plant. Consider synthetic soil-like media, or mixtures of peat moss, wood chips, and perlite for various species.
Be sure to prepare the soil before planting, or use a synthetic medium. This makes water control easier. It is important to balance adequate drainage and good retention of moisture to keep container-grown plants healthy. Place some marbles at the bottom of the container to keep holes from clogging and to ensure proper drainage. Mix in commercial soil prep to break up clay particles.
Even when the soil or medium is well prepared, water with care. When containers are near a window, soil can easily dry out. It's easy to introduce root rot by over watering or to forget whether watering chores were completed, so keep a soil moisture tester nearby.
In most cases, soil straight from the outdoors isn't a good choice for containers. Very clay-like soil outdoors can be compensated for somewhat by natural features that drain the water away. In a container, the strong ability of clay to retain water is exaggerated. Very sandy soil will need to be built up. If that much effort is required to adjust outdoor soil, it's easier just to buy professionally prepared media.
Most vegetables need plenty of sunlight. You can anticipate a great crop of tomatoes if you place them in a south-facing windowsill that receives several hours of sunlight each day. Tomato plants also thrive in the heat, so there's a low-risk of burning them. There are other vegetables, like lettuce, that prefer less direct sunlight. Place these in partial shade. When you are container gardening, it's easy to move your plants in varied weather.
Whether your plants sit outside or are kept indoors, pests are able to find them. Be on the watch for insects as you would in an outdoor garden. Larvae can develop in the soil of container plants if the eggs were laid in the soil before planting. When used according to specification, insecticide soaps and other commercial mixtures are safe for treating plants, and safe for you when you eat the plants.
Having fresh vegetables readily available offers convenience and healthful options for your diet. Though container gardening requires some effort, the rewards are well worth the time investment.