diff --git a/docker/utils/utils.py b/docker/utils/utils.py
index <HASH>..<HASH> 100644
--- a/docker/utils/utils.py
+++ b/docker/utils/utils.py
@@ -36,6 +36,7 @@ def mkbuildcontext(dockerfile):
                             'Dockerfiles with Python 3')
         else:
             dfinfo.size = len(dockerfile.getvalue())
+            dockerfile.seek(0)
     elif isinstance(dockerfile, io.BytesIO):
         dfinfo = tarfile.TarInfo('Dockerfile')
         dfinfo.size = len(dockerfile.getvalue())
Should be done for StringIO objects as well