def pull_image(self, image_name, stream=None):
stream_writer = stream or StreamWriter(sys.stderr)<EOL>try:<EOL><INDENT>result_itr = self.docker_client.api.pull(image_name, stream=True, decode=True)<EOL><DEDENT>except docker.errors.APIError as ex:<EOL><INDENT>LOG.debug("<STR_LIT>", image_name)<EOL>raise DockerImagePullFailedException(str(ex))<EOL><DEDENT>stream_writer.write(u"<STR_LIT>".format(image_name))<EOL>for _ in result_itr:<EOL><INDENT>stream_writer.write(u'<STR_LIT:.>')<EOL>stream_writer.flush()<EOL><DEDENT>stream_writer.write(u"<STR_LIT:\n>")<EOL>
Ask Docker to pull the container image with given name.

Parameters
----------
image_name str
    Name of the image
stream samcli.lib.utils.stream_writer.StreamWriter
    Optional stream writer to output to. Defaults to stderr

Raises
------
DockerImagePullFailedException
    If the Docker image was not available in the server