title: docker-py : Docker Python sdk container.put_archive not working
body: <p>I have copied a example.py file from local system to container using put_archive under /root/ directory. I want to run the file in container. The file is not found in container. Here is my code: What's wrong in my code ? I expect put_archive should copy a file example.py under /root directory. The file is not found in container.</p>
  <pre><code>import docker
  import os
  import tarfile
  import time
  import json
  from io import BytesIO
  
  client = docker.from_env()
  image = client.images.pull(&quot;malark79/ibm-cloud-python-sdk&quot;)
  
  container = client.containers.run(&quot;malark79/ibm-cloud-python-sdk&quot;, &quot;pwd&quot;, detach=True)
  print(&quot;Docker logs: &quot; + str(container.logs()))
  
  print(container.id)
  print(container.name)
  print(container.image)
  
  f = open(&quot;example.py&quot;, &quot;w&quot;) //open local file
  with tarfile.open(&quot;example.py.tar.gz&quot;, &quot;w:gz&quot;) as tar:
          tar.add(f.name, arcname=os.path.basename(f.name))
  t = open(&quot;example.py.tar.gz&quot;, &quot;rb&quot;)
  
  works = container.put_archive(&quot;/root/&quot;, data=t)
  
  t.close()
  if not works:
          print(&quot;Can't create file in container&quot;)
  
  container = client.containers.run(&quot;malark79/ibm-cloud-python-sdk&quot;, &quot;ls -al /root&quot;, detach=True)
  print(&quot;Docker logs: &quot; + str(container.logs())) ### does not display file example.py
  
  container = client.containers.run(&quot;malark79/ibm-cloud-python-sdk&quot;, &quot;/usr/bin/python3 /root/example.py&quot;, detach=True)
  print(&quot;Docker logs: &quot; + str(container.logs()))  ### [Errno 2] No such file or directory\n&quot;
  
    
  </code></pre>