Docker image with custom user: Permission denied when building

Hi.

I am working on a private project to get a basic idea of CI for hardware development (FPGAs, VHDL and stuff). I’ve created a custom docker image containing the xilinx software vivado, using a custom user “xilinx”.

Now I want to use this docker image to build the FPGA-binaries with a simple drone file:

kind: pipeline
type: docker
name: vivado

steps:
- name: build
  image: vivado
  pull: never
  commands: 
  - /bin/bash -c "source /tools/Xilinx/Vivado/2020.2/settings64.sh && vivado -mode tcl -source ./tcl/create_project.tcl"

When executed, the docker image reports:
“Please check access permission of directory ‘/drone/src’. You should restart the application from a writable working directory.”

When I change the drone file to provide some info, I get the following results:

+ pwd
/drone/src

+ whoami
xilinx

+ ls -al /drone
total 12
drwxr-xr-x 3 root root 4096 May  3 06:15 .
drwxr-xr-x 1 root root 4096 May  3 06:15 ..
drwxr-xr-x 3 root root 4096 May  3 06:15 src

+ ls -al /drone/src
total 16
drwxr-xr-x 3 root root 4096 May  3 06:15 .
drwxr-xr-x 3 root root 4096 May  3 06:15 ..
-rw-r--r-- 1 root root  203 May  3 06:15 .drone.yml
drwxr-xr-x 8 root root 4096 May  3 06:15 .git

So it looks like the git repository is inserted for user root, chmod 755.
Is there a way to change this? Or do I have to always use the root user in docker images?

This is because /drone/src is a docker volume, and when docker creates a volume it is owned by root. If your image defaults to a non-root user, it means it will be unable to write to the volume. You can override the default user in your yaml by adding user: root to the step.

- name: <name>
  image: <image>
  user: root
1 Like

Thank you very much for your help.
It works like a charm now.