that actually depends on a lot of different things. Some people believe that passing around the container is actually bad practice and you should just pass in the services you need instead of pulling them from the container.
For the projects i've worked on that were ok with passing in the container, generally when we created a service we defined the class as a service and injected it in the services.yml, however , when dealing with commands, dispatchers, etc we would just extend the "containerAwareCommand" or "containerAwareEventDispatcher" respectively. The reasoning behind this was that they wanted greater control of their services, but when using things that were specific to symfony (such as the commands) it was probably better to subscribe to the framework methodology.