1

This may seem like duplicate question? But I think it's not, and also. I have tried google.

This is the situation, I want to build a CI pipeline with Gogs and Drone, with their nice documents, I have build it up. But now, I am stucking on: How to copy files from container to the host in the container. below is my drone yml config.

pipeline:
build:
  image: node:7
  commands:
    - cd client
    - npm config set registry https://registry.npm.taobao.org
    - npm install --no-optional
    - yarn run build
    - sudo docker cp $(sudo docker ps -alq):$PWD/build /var/www/react/ 

The CI ends with error:

/bin/sh: sudo: not found

after try without sudo, error continues:

/bin/sh: docker: not found

The answers I found are all about copy files to host from container which the shell runs in host computer. but now the commands I tried to run is in the container, so What should i do? or I miss something.

Kevin Kopf
  • 13,327
  • 14
  • 49
  • 66
Tab Gre
  • 57
  • 1
  • 9

1 Answers1

1

you could mount a volume on the container - a volume is a directory mapping from the host to the container - a shared folder between the two

In the container, you would then copy the files you want to the shared folder and the host could access them in the shared folder.

Don't copy the files into the shared folder before mounting has finished. If you do, the files will not be accessible.

Here's the docs on volumes:

https://docs.docker.com/storage/volumes/#create-and-manage-volumes

danday74
  • 52,471
  • 49
  • 232
  • 283