use Symfony\Component\Console\Command\Command; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; class MyCommand extends Command { protected function configure() { $this->setName('my-command') ->setDescription('My command description'); } protected function execute(InputInterface $input, OutputInterface $output) { $container = $this->getApplication()->getKernel()->getContainer(); $myService = $container->get('app.my_service'); // Use the $myService instance here. } }In this example, setContainer() is not explicitly called, but it is called implicitly by the parent Command class when the command is executed. The command then gets the container from the application kernel and uses it to retrieve an instance of the MyService service. The package library that provides the setContainer() method is Symfony Console component.