gitness
gitness copied to clipboard
Mount host volume to container
It is not clear how to use volumes, or maybe it is a bug
I start the gitness
container and mount /tmp/foo
to container
docker run -d \
-p 3000:3000 \
-v /var/run/docker.sock:/var/run/docker.sock \
-v /opt/gitness:/data \
-v /tmp/foo:/tmp \
--name gitness \
--restart always \
harness/gitness
The goal is to get artifacts from the container to the host system. I can't get it working and tried several ways.
Pipeline:
kind: pipeline
spec:
stages:
- type: ci
spec:
steps:
- name: step01
type: run
spec:
container:
image: alpine:3
pull: if-not-exists
volumes:
- name: tmp
spec: host
path: /tmp/foo
script: |-
echo "example" > /tmp/foo.txt
ls -la /tmp
echo "# content of /tmp/foo.txt"
cat /tmp/foo.txt
volumes:
- type: volume
spec: host
spec:
path: /tmp/foo
I can see it in the container:
step01
+ echo "example" > /tmp/foo.txt\nls -la /tmp\necho "# content of /tmp/foo.txt"\ncat /tmp/foo.txt total 12 drwxrwxrwt 1 root root 4096 Jan 7 17:45 . drwxr-xr-x 1 root root 4096 Jan 7 17:45 .. -rw-r--r-- 1 root root 8 Jan 7 17:45 foo.txt # content of /tmp/foo.txt example
But I don't see this file from the host who starts container gitness
sever@sever:~/scripts/other/gitness$ ls -la /tmp/foo/
total 16
drwxr-xr-x 2 root root 4096 Jan 7 19:44 .
drwxrwxrwt 8 root root 12288 Jan 7 19:45 ..
sever@sever:~/scripts/other/gitness$
I would be grateful if this is possible.
I spent several days, and it doesn't work for some reason.
I tried --privileged
as in host as in the pipeline, I tried sudo
I try ~10-15 variants of config
volumes:
- type: volume
name: vol
spec: host
path: /tmp/foo:/tmp/foo
kind: pipeline
type: docker
name: default
steps:
- name: hello
privileged: true
image: alpine:3
volume:
name: vol
path:
/tmp/foo
commands:
- mkdir /tmp/foo
- ls -la
- cat /etc/os-release
- touch /tmp/foo/example.txt
I can't get it working.
I just want to ask, is it possible at all or should we don't do it anymore?
There is no information about it. And Slack it seems requires only accounts with a harness
domain, impossible to register with other mails.
As I understand it is just not implemented.
If you need any debug or help with this implementation let me know.
I can contribute if you point me to at least the part of the code where I should look. As a workaround with scp
looks really ugly.
Thanks.
I also tried using 'mount'. No success.