Dockerfile COPY files to /drone not working

Hi, I have a .drone.yml looking something like this:

    image: felixmulder/dotty:0.1
    pull: true
      - ls -la /drone
      - cp /drone/scala-scala .
      - ./scripts/jobs/validate/junit

The image felixmulder/dotty:0.1 has the following Dockerfile:

FROM 1science/sbt:0.13.8-oracle-jre-8

# Add git to image
RUN apk add --update git

WORKDIR /drone

# Clone the modified standard library for testing, then copy it via the .drone.yml file
RUN git clone -b dotty-library scala-scala

# Add ivy2 cache
COPY ivy2/ ivy2

When running and attaching to the dotty image on my machine I can see the directories ivy2 and scala-scala in /drone. But the commands in the .drone.yml file fail because there is nothing (except src) in /drone when the CI is running.

I’m sure I’m missing something obvious as I’m fairly new to both docker and drone.


The problem is that /drone is a reserved path, by default, for every build. It is the path at which your build workspace (where your code is cloned) is mounted as a volume.

Let’s say we have the following Yaml file:

    image: golang
      - go build
      - go test

The build container is started with a shared volume mounted at /drone. You can think of it like drone running the following docker commands:

docker volume add drone-volume-for-build
docker run --volume=drone-volume-for-buid:/drone golang:latest

The volume mounted at /drone is therefore mounted on top of the /drone directory you created in your dockerfile, which is why it isn’t visible during the build. This can be resolved by using a different cache path in your Dockerfile:

-WORKDIR /drone
-COPY ivy2/ ivy2
+WORKDIR /var/cache/drone
+COPY ivy2/ ivy2

OR this can be resolved by changing the default Drone workspace path for your build. The below example overrides the default workspace to use /code instead of /drone as the base volume.

+ base: /code

    image: golang
      - go build
      - go test

You can read more about the workspace in the 0.5 documentation at

1 Like

Thanks! Now everything works :smile:

I’m sorry, but I do not understand something here. Are you sharing the file/folder between the docker pipelines ? Is that what you’re achieving ?

the volume is shared between all steps in the same pipeline (it is not shared across pipelines). For a more detailed explanation see