Copying files to a local/host directory

10/24/2018

I am trying to copy files from a container to a local/host directory. Running my experiments on minikube. Tried starting minikube with a mount as: minikube mount /tmp/export:/data/export and it still does not work.

I have a single pod, that upon startup runs a simple script:

timeout --signal=SIGINT 10s clinic bubbleprof -- node index.js >> /tmp/clinic.output.log && \
  cp -R `grep "." /tmp/clinic.output.log | tail -1 | grep -oE '[^ ]+
#x27;
`* /data/export/ && \ echo "Finished copying clinic run generated files"

Once my script finishes its run, the container dies. This happens because bash is the process with PID 1. I don't mind this. My problem is that /tmp/export is empty, after the files should have been copied out.

My pod yaml:

apiVersion: v1
kind: Pod
metadata:
  name: clinic-testapp
spec:
  containers:
  - name: clinic-testapp
    image: username/container-image:0.0.11
    ports:
    - containerPort: 80
    volumeMounts:
    - name: clinic-storage
      mountPath: /data/export
  volumes:
  - name: clinic-storage
    hostPath:
     path: /tmp/export

Am I doing something wrong? Please advise.

-- Moshe Shmukler
kubernetes
minikube

0 Answers