title: how to rsync from a host computer to docker container using docker cp
body: <p>I am trying to run following:</p>
  
  <ol>
  <li>start a container in background</li>
  </ol>
  
  <p><code>docker run -dit -p 8090:80 --name container repository:dockerfile bash</code></p>
  
  <ol start="2">
  <li>I want to exclude sub directory <code>/data</code> from <code>/test</code> </li>
  </ol>
  
  <p><code>docker cp /Users/$USER/test container:/test</code></p>
  
  <ol start="3">
  <li>I thought of using rsync for this
  <code>docker exec rsync -avP  --exclude /Users/$USER/test/data /Users/$USER/test/ container:/test/</code></li>
  </ol>
  
  <p>I get below error:</p>
  
  <pre><code>rsync: Failed to exec ssh: No such file or directory (2)
  rsync error: error in IPC code (code 14) at pipe.c(85) [sender=3.1.0]
  rsync: connection unexpectedly closed (0 bytes received so far) [sender]
  rsync error: error in rsync protocol data stream (code 12) at io.c(226)
  [sender=3.1.0]
  </code></pre>
  
  <p>How do I rsync from host to container?</p>