<!-- Love localstack? Please consider supporting our collective:
👉  https://opencollective.com/localstack/donate -->
We have several Kinesis streams set up with event notifications that trigger lambdas.  When the LAMBDA_EXECUTOR is set to 'docker' and we send a large number or records to Kinesis, multiple Lambdas will execute, but currently they are failing to create with error:

```
Exception: Lambda process returned error status code: 1. Output:
time="2019-09-18T17:28:11Z" level=error msg="error getting events from daemon: net/http: request canceled" 
Error response from daemon: driver failed programming external connectivity on endpoint busy_sanderson (a78e45a41d0ce5b0d8bab6ff54344fc34fe2b4969f55bf568e753121abc8759e): Bind for 0.0.0.0:38763 failed: port is already allocated
```

I believe this is due to the new debug_java_port introduced with this PR https://github.com/localstack/localstack/pull/1523

With this change, you are setting the port in the constructor by using a method known to have a race condition (https://github.com/localstack/localstack/blob/master/localstack/utils/common.py#L354)
(https://gist.github.com/gabrielfalcao/20e567e188f588b65ba2)

This should be changed to ensure unique ports are being issued across all lambdas


"""
    Extracts a Zipfile entry and preserves permissions
    """
    zip_ref.extract(file_entry.filename, path=target_dir)
    out_path = os.path.join(target_dir, file_entry.filename)
    perm = file_entry.external_attr >> 16
    os.chmod(out_path, perm or 0o777)
def is_jar_archive(content):
    """ Determine whether `content` contains valid zip bytes representing a JAR archive
        that contains at least one *.class file and a META-INF/MANIFEST.MF file. """
    try:
        with tempfile.NamedTemporaryFile() as tf:
            tf.write(content)
            tf.flush()
            with zipfile.ZipFile(tf.name, 'r') as zf:
                class_files = [e for e in zf.infolist() if e.filename.endswith('.class')]
                manifest_file = [e for e in zf.infolist() if e.filename.upper() == 'META-INF/MANIFEST.MF']
                if not class_files or not manifest_file:
                    return False
    except Exception:
        return False
    return True
def is_root():
    out = run('whoami').strip()
    return out == 'root'
def cleanup_resources():
    cleanup_tmp_files()
    cleanup_threads_and_processes()
def generate_ssl_cert(target_file=None, overwrite=False, random=False):