Copy from docker to host inside CI build
<p>I would like to know if it would be possible to somehow copy file/folder from inside docker to host but copying itself is executed form inside docker.</p>

<p>The reason is that, for example:</p>

<ul>
<li>Commit file to repo</li>
<li>CI kicks in</li>
<li>Docker installs dependencies, builds the website files</li>
<li>Website files is copied from docker to /var/www/my-website (host)</li>
</ul>

<p>When I was searching for a solution I've seen this command a lot <code>docker cp &lt;containerId&gt;:/file/path/within/container /host/path/target</code> however this is executed from HOST. I want to make the whole process automated.</p>

<p>Possible solution of course is to not use docker but straight-up SSH, that's what I'm doing now, but that is not the best option IMO.</p>

<p>Here is example of my <code>.gitlab-ci.yml</code> file that will explain what I want to achieve.</p>

<pre><code>image: ubuntu:16.04

build:
    stage: build
    script:
        - apt-get update
        - apt-get upgrade -yy
        - apt-get install hugo -yy # Static site generator
        - hugo build # Build the website
        - cp -R ./build/* /var/www/my-website/ # Copy to the web root
</code></pre>

<p>Here is my runner configuration</p>

<pre><code>[[runners]]
  name = "DOCKER-TEST"
  url = "https://gitlab.com/ci"
  token = "{{token}}"
  executor = "docker"
  [runners.docker]
    tls_verify = false
    image = "ubuntu:16.04"
    privileged = true
    disable_cache = false
    volumes = ["/cache", "/home/stan:/builds/stanislavromanov/test-docker:rw"]
  [runners.cache]
    Insecure = false
</code></pre>