I am new to Drone.
But thanks to its superpowers and some help from this forum, I have automated most of the docker image building I intended to and am very happy about it.
However, I still stumble on something I do not understand and would need some help with.
Here is what I would like to do:
- I am using a private docker registry at
192.168.1.46:5000
. - I want to build an image from Alpine
- then push the newly built image to the registry
I have already done it several times successfully but would like to improve the process speed by mounting a directory during the build process where installation files are cached.
So, I would like to mount a volume from the host into the image while I am building it.
It is well known there is no MOUNT
instruction for dockerfiles, so I tried this (knowing that the initiating git repo is mounted by default at /drone/src/
then at root
within the docker image):
- in the
drone.yml
file, I mount the host volume into a subdirectory of/drone/src
:
kind: pipeline
type: docker
name: test
steps:
- name: publish
image: plugins/docker
volumes:
- name: thevol
path: /drone/src/thevol
settings:
repo: 192.168.1.46:5000/vsr-tst
registry: 192.168.1.46:5000
auto_tag: false
insecure: true
pull: if-not-exists
tags: drnbld_${DRONE_BUILD_NUMBER}
volumes:
- name: thevol
host:
path: /home/thevol
- then in the
Dockerfile
I check if I can access the volume atroot
:
# I pull Alpine
FROM alpine/git
# Copying a file that belongs to the initiating git repo > OK
COPY README_GIT.md /somewhere
# Copying a file that is in the volume I tried to mount inside the `/drone/src directory` > NOK
COPY /thevol/README_MOUNT.md /somewhere_else
- I cannot copy the file and instead get an error during the build:
Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?
exit status 1
- As soon as I remove the
volumes:
instruction block nested in thepublish
step in thedrone.yml
file, everything works fine again.
Thanks for your help.
S.