def create_dockerfile(dockerfile, tag, pythons):
    """Create a Dockerfile.

    Args:
        dockerfile: The path to the dockerfile.
        tag: The tag assigned after 'FROM' in the first line of the dockerfile.
        pythons: A list of python versions. Example: ['2.7.12', '3.4.1']

    Returns:
        The contents of the dockerfile created.
    """
    contents = []
    with open(dockerfile, 'w') as dfile:
        contents.append('FROM {tag}\n'.format(tag=tag))

        for python in pythons:
            contents.append('RUN pyenv install {python}\n'.format(python=python))

        dfile.writelines(contents)

    return contents