### Is there an existing issue for this?

- [X] I have searched the existing issues

### Current Behavior

after mounting my local stack with docker compose
creating a function with boto3
Be sure my function is well created by checking in with a BOTO3 get_function.

And trying to invoke the function with Boto3 invoke function i get an error as response

```
{
   "errorMessage":"expected string or bytes-like object",
   "errorType":"TypeError",
   "stackTrace":[
      "  File \"/opt/code/localstack/localstack/services/awslambda/lambda_api.py\", line 734, in run_lambda\n    callback=callback,\n",
      "  File \"/opt/code/localstack/localstack/services/awslambda/lambda_executors.py\", line 224, in execute\n    return do_execute()\n",
      "  File \"/opt/code/localstack/localstack/services/awslambda/lambda_executors.py\", line 214, in do_execute\n    return _run(func_arn=func_arn)\n",
      "  File \"/opt/code/localstack/localstack/utils/cloudwatch/cloudwatch_util.py\", line 157, in wrapped\n    raise e\n",
      "  File \"/opt/code/localstack/localstack/utils/cloudwatch/cloudwatch_util.py\", line 153, in wrapped\n    result = func(*args, **kwargs)\n",
      "  File \"/opt/code/localstack/localstack/services/awslambda/lambda_executors.py\", line 201, in _run\n    raise e\n",
      "  File \"/opt/code/localstack/localstack/services/awslambda/lambda_executors.py\", line 189, in _run\n    result = self._execute(func_arn, func_details, event, context, version)\n",
      "  File \"/opt/code/localstack/localstack/services/awslambda/lambda_executors.py\", line 535, in _execute\n    return super(LambdaExecutorReuseContainers, self)._execute(func_arn, *args, **kwargs)\n",
      "  File \"/opt/code/localstack/localstack/services/awslambda/lambda_executors.py\", line 441, in _execute\n    cmd = self.prepare_execution(func_details, environment, command)\n",
      "  File \"/opt/code/localstack/localstack/services/awslambda/lambda_executors.py\", line 497, in prepare_execution\n    container_info = self.prime_docker_container(func_details, env_vars, lambda_cwd)\n",
      "  File \"/opt/code/localstack/localstack/services/awslambda/lambda_executors.py\", line 577, in prime_docker_container\n    cmd = self.get_container_startup_command(func_details, env_vars, lambda_cwd)\n",
      "  File \"/opt/code/localstack/localstack/services/awslambda/lambda_executors.py\", line 632, in get_container_startup_command\n    lambda_cwd_on_host = Util.get_host_path_for_path_in_docker(lambda_cwd)\n",
      "  File \"/opt/code/localstack/localstack/services/awslambda/lambda_executors.py\", line 1072, in get_host_path_for_path_in_docker\n    return re.sub(r\"^%s/(.*)$\" % config.TMP_FOLDER, r\"%s/\\1\" % config.HOST_TMP_FOLDER, path)\n",
      "  File \"/usr/lib/python3.7/re.py\", line 194, in sub\n    return _compile(pattern, flags).sub(repl, string, count)\n"
   ]
}
```


The docker stack log say me pretty the same thing.

```
localstack_1  | 2021-08-16 12:25:45,422:API: 127.0.0.1 - - [16/Aug/2021 12:25:45] "POST / HTTP/1.1" 200 -
localstack_1  | 2021-08-16T12:25:45:INFO:localstack.services.awslambda.lambda_api: Error executing Lambda function arn:aws:lambda:us-east-1:000000000000:function:testlambda2: expected string or bytes-like object Traceback (most recent call last):
localstack_1  |   File "/opt/code/localstack/localstack/services/awslambda/lambda_api.py", line 734, in run_lambda
localstack_1  |     callback=callback,
localstack_1  |   File "/opt/code/localstack/localstack/services/awslambda/lambda_executors.py", line 224, in execute
localstack_1  |     return do_execute()
localstack_1  |   File "/opt/code/localstack/localstack/services/awslambda/lambda_executors.py", line 214, in do_execute
localstack_1  |     return _run(func_arn=func_arn)
localstack_1  |   File "/opt/code/localstack/localstack/utils/cloudwatch/cloudwatch_util.py", line 157, in wrapped
localstack_1  |     raise e
localstack_1  |   File "/opt/code/localstack/localstack/utils/cloudwatch/cloudwatch_util.py", line 153, in wrapped
localstack_1  |     result = func(*args, **kwargs)
localstack_1  |   File "/opt/code/localstack/localstack/services/awslambda/lambda_executors.py", line 201, in _run
localstack_1  |     raise e
localstack_1  |   File "/opt/code/localstack/localstack/services/awslambda/lambda_executors.py", line 189, in _run
localstack_1  |     result = self._execute(func_arn, func_details, event, context, version)
localstack_1  |   File "/opt/code/localstack/localstack/services/awslambda/lambda_executors.py", line 535, in _execute
localstack_1  |     return super(LambdaExecutorReuseContainers, self)._execute(func_arn, *args, **kwargs)
localstack_1  |   File "/opt/code/localstack/localstack/services/awslambda/lambda_executors.py", line 441, in _execute
localstack_1  |     cmd = self.prepare_execution(func_details, environment, command)
localstack_1  |   File "/opt/code/localstack/localstack/services/awslambda/lambda_executors.py", line 497, in prepare_execution
localstack_1  |     container_info = self.prime_docker_container(func_details, env_vars, lambda_cwd)
localstack_1  |   File "/opt/code/localstack/localstack/services/awslambda/lambda_executors.py", line 577, in prime_docker_container
localstack_1  |     cmd = self.get_container_startup_command(func_details, env_vars, lambda_cwd)
localstack_1  |   File "/opt/code/localstack/localstack/services/awslambda/lambda_executors.py", line 632, in get_container_startup_command
localstack_1  |     lambda_cwd_on_host = Util.get_host_path_for_path_in_docker(lambda_cwd)
localstack_1  |   File "/opt/code/localstack/localstack/services/awslambda/lambda_executors.py", line 1072, in get_host_path_for_path_in_docker
localstack_1  |     return re.sub(r"^%s/(.*)$" % config.TMP_FOLDER, r"%s/\1" % config.HOST_TMP_FOLDER, path)
localstack_1  |   File "/usr/lib/python3.7/re.py", line 194, in sub
localstack_1  |     return _compile(pattern, flags).sub(repl, string, count)
localstack_1  | TypeError: expected string or bytes-like object
```



### Expected Behavior

Having the lambda to run  and return me the output of my function

### How are you starting LocalStack?

With a docker-compose file

### Steps To Reproduce

build image from my app.py

app.py content:

```
import json
from time import sleep

def handler(event,context):
    #the sleep timer is just to have enougth time to see what happen when function is called
    sleep(5)
    return {
        'statusCode': 200,
        'body': json.dumps({"event":event,"message":"hello from localstack"})
            }
```

Build it and tag it locally.
`docker build -t testlambda -f Dockerfile .`

with following docker file

```
FROM public.ecr.aws/lambda/python:3.8

# Copy function code
COPY app.py ${LAMBDA_TASK_ROOT}

# Install the function's dependencies using file requirements.txt
# from your project folder.

COPY requirements.txt  .
RUN  pip3 install -r requirements.txt --target "${LAMBDA_TASK_ROOT}"

# Set the CMD to your handler (could also be done as a parameter override outside of the Dockerfile)
CMD [ "app.handler" ] 
```

_NB: try to dirrectly invoke lambda by launching my lambda image
`docker run -p 9000:8000 testlambda:latest and it works`
and query it with a curl
It works._

Create my local network on docker 
`docker network create -d bridge localstacknet`

Now launch my local stack from a docker-compose.yml as following.

```
version: '3.3'
services:
  localstack:
    image: localstack/localstack:0.12.15
    
    ports:
      - "53:53"
      - "443:443"
      - "4566-4583:4566-4583"
    environment:
      - DATA_DIR=/tmp/localstack/data
      - DEBUG=1
      - DOCKER_HOST=unix:///var/run/docker.sock
      - HOSTNAME_EXTERNAL=localstack
      - HOST_TMP_FOLDER= E:/Sources/container_Lambda/storage_localstack
      - LAMBDA_EXECUTOR=docker-reuse
      - LAMBDA_REMOVE_CONTAINERS=true
      - LAMBDA_REMOTE_DOCKER=true
      - LAMBDA_DOCKER_NETWORK= localstacknet
      - SERVICES=lambda,s3,iam,cloudwatch,dynamodb
    volumes:
      - "/var/run/docker.sock:/var/run/docker.sock"
      - "E:/Sources/container_Lambda/storage_localstack/TMP:/tmp/localstack"
    networks:
      - localstacknet
    
    privileged: true

  
networks:
  localstacknet:
    external: true
    driver : bridge
    name: localstacknet
```

use boto3 to connect to local stack and create function.

Get the error when trying to invoke








### Environment

```markdown
- OS: Windows
- LocalStack: 0.12.15
```


### Anything else?

_No response_
if Util.debug_java_port:
            docker_java_ports.add(Util.debug_java_port)
        docker_image = Util.docker_image_for_lambda(func_details)
        if config.LAMBDA_REMOTE_DOCKER:
            container_id = DOCKER_CLIENT.create_container(
                image_name=docker_image,
                interactive=True,
                entrypoint=entrypoint,
                remove=True,
                network=network,
                env_vars=env_vars,
                dns=dns,
                additional_flags=additional_flags,
                ports=docker_java_ports,
                command=command,
            )
            DOCKER_CLIENT.copy_into_container(container_id, f"{lambda_cwd}/.", DOCKER_TASK_FOLDER)
            return DOCKER_CLIENT.start_container(
                container_id, interactive=not background, attach=not background, stdin=stdin
            )
        else:
            mount_volumes = None
            if lambda_cwd:
                mount_volumes = [
                    (Util.get_host_path_for_path_in_docker(lambda_cwd), DOCKER_TASK_FOLDER)
                ]
            return DOCKER_CLIENT.run_container(
                image_name=docker_image,
                interactive=True,
                detach=background,