[docker] How to copy files from host to Docker container?

Another solution for copying files into a running container is using tar:

tar -c foo.sh | docker exec -i theDockerContainer /bin/tar -C /tmp -x

Copies the file foo.sh into /tmp of the container.

Edit: Remove reduntant -f, thanks to Maartens comment.