# Steps to reproduce

* Run `localstack` with `LAMBDA_EXECUTOR=docker` and `LAMBDA_REMOTE_DOCKER=true`.
* Create and execute multiple lambda functions.
* Run `docker ps -a` and observe multiple `lambci` containers

This does not happen with `LAMBDA_EXECUTOR=docker-reuse` or with `LAMBDA_REMOTE_DOCKER=true`
super(LambdaExecutorReuseContainers, self).__init__()
        
        self.docker_container_lock = threading.RLock()
        
        
        
        
        self.next_port = 0
        self.max_port = LAMBDA_SERVER_UNIQUE_PORTS
        self.port_offset = LAMBDA_SERVER_PORT_OFFSET
    def prepare_execution(self, func_arn, env_vars, runtime, command, handler, lambda_cwd):
        
        has_been_invoked_before = func_arn in self.function_invoke_times
        
        with self.docker_container_lock:
            env_vars['_LAMBDA_SERVER_PORT'] = str(self.next_port + self.port_offset)
            self.next_port = (self.next_port + 1) % self.max_port
        
        LOG.debug('Priming docker container with runtime "%s" and arn "%s".', runtime, func_arn)
        container_info = self.prime_docker_container(runtime, func_arn, env_vars.items(), lambda_cwd)
        
        
        
        exec_env_vars = ' '.join(['-e {}="${}"'.format(k, k) for (k, v) in env_vars.items()])
        if not command:
            command = '%s %s' % (container_info.entry_point, handler)
        
        copy_command = ''
        docker_cmd = self._docker_cmd()
        event_file = os.path.join(lambda_cwd, LAMBDA_EVENT_FILE)