Sta*_*tan 5 continuous-integration docker gitlab-ci
我想知道是否有可能以某种方式将文件/文件夹从docker内部复制到主机,但是复制本身是在docker内部执行的.
原因是,例如:
当我在寻找解决方案时,我已经看到了很多这个命令,docker cp <containerId>:/file/path/within/container /host/path/target但这是从HOST执行的.我想让整个过程自动化.
当然可能的解决方案是不使用docker而是使用直接SSH,这就是我现在正在做的事情,但这不是IMO的最佳选择.
这是我的.gitlab-ci.yml文件示例,它将解释我想要实现的目标.
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
Run Code Online (Sandbox Code Playgroud)
这是我的跑步者配置
[[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
Run Code Online (Sandbox Code Playgroud)
    您应该能够设置Docker 卷,其中容器中的目录安装到主机的目录中.
对于GitLab CI跑步者,可以在跑步者注册期间或之后通过修改/etc/gitlab-runner/config.toml指定.例:
[[runners]]
  url = "https://gitlab.com/ci"
  token = TOKEN
  executor = "docker"
  [runners.docker]
    tls_verify = false
    image = "ubuntu:16.04"
    privileged = true
    disable_cache = false
    volumes = ["/path/to/bind/from/host:/path/to/bind/in/container:rw"]
Run Code Online (Sandbox Code Playgroud)
有关详细信息,请参阅文档
|   归档时间:  |  
           
  |  
        
|   查看次数:  |  
           5791 次  |  
        
|   最近记录:  |