def create_core_file(duthost, docker_name=None):
    """
    Create .core file in SONiC or inside in docker container
    :param duthost: duthost object
    :param docker_name: docker name - in case when you need to create .core file inside in docker container
    """
    cmd = 'bash /etc/sonic/core_file_generator.sh'
    if docker_name:
        cmd = 'docker exec {} {}'.format(docker_name, cmd)

    available_core_files = duthost.shell('ls /var/core/')['stdout_lines']
    duthost.shell(cmd)
    new_available_core_files = duthost.shell('ls /var/core/')['stdout_lines']
    new_core_files = list(set(new_available_core_files) - set(available_core_files))
    num_of_new_core_files = len(new_core_files)
    expected_num_of_new_core_files = 1
    if not new_core_files:
        raise AssertionError('Core file was not generated')
    assert num_of_new_core_files == expected_num_of_new_core_files, 'More than expected number of core files generated'
    new_core_file_name = new_core_files[0]
    return new_core_file_name