def METHOD_NAME(args):
    """Builds a docker image with the latest snapshot."""
    target = args.target
    targetNoDot = target.replace(".", "")
    # Create a temporary directory
    tmpdir = tempfile.mkdtemp()
    try:
        # Get latest snapshot info.
        latest_build_url = "https://swift.org/builds/development/ubuntu{}/latest-build.yml".format(targetNoDot)
        latest_build_data = yaml.safe_load(urllib2.urlopen(latest_build_url).read())
        snapshot_filename = latest_build_data["download"]
        # FIXME: We shouldn"t need to do this, it should be available in the API.
        snapshot_name = snapshot_filename.replace("-ubuntu{}.tar.gz".format(target), "")
        base_url = latest_build_url.rsplit("/", 1)[0]
        latest_snapshot_url = base_url + "/" + snapshot_name + "/" + snapshot_filename
        docker_dir = os.path.dirname(os.path.realpath(__file__))
        # Check if we already have the desired snapshot image
        curImages = subprocess.check_output([
            "docker",
            "images",
            "--filter", "reference=llbuild-docker-{}:latest".format(targetNoDot),
            "--filter", "label=swift-snapshot={}".format(snapshot_name),
            "--format", "{{.ID}}"
        ])
        # Download latest snapshot (if necessary).
        if len(curImages.split()) == 1:
            print("Image exists for {} with {}".format(target, snapshot_name))
            exit(0)
        else:
            result = call([
                "docker",
                "rmi", "-f",
                "llbuild-docker-{}".format(target)
            ])
            if result != 0:
                print("Unable to clean prior images")
                exit(1)
            result = call([
                "curl",
                "-o",
                os.path.join(tmpdir, snapshot_filename),
                latest_snapshot_url
            ])
            if result != 0:
                print("Unable to fetch snapshot")
                exit(1)
        # Create docker image.
        call([
            "docker",
            "build",
            "-t", "llbuild-docker-{}".format(targetNoDot),
            "--label", "swift-snapshot={}".format(snapshot_name),
            "--build-arg", "SNAPSHOT=%s" % snapshot_filename,
            "--file", os.path.join(docker_dir, "Dockerfile-{}".format(target)),
            tmpdir
        ])
    finally:
        shutil.rmtree(tmpdir)