I'm trying to run a simple command with docker that read a file in my home directory and write an output file in the same directory on my local machine (/home/userxyz/projects/data
). The data
folder belongs to me (userxyz
) and my group which has the same name (userxyz
) with R/W permissions.
I built an image with a Dockerfile like so (following How to add users to Docker container?):
FROM osgeo/gdal:alpine-small-latest
RUN mkdir /usr/tmp
RUN addgroup -S userxyz \
&& adduser -S -D -h /usr/tmp userxyz userxyz \
&& chown -R userxyz:userxyz /usr/tmp
USER userxyz
WORKDIR /usr/tmp
and:
docker build -t userxyz/test .
I ran docker with:
docker run --rm -v /home/userxyz/projects/data:/usr/tmp userxyz/test gdal_translate -ot UInt32 /usr/tmp/input.tif /usr/tmp/output.tif
However, I still get:
ERROR 4: Attempt to create new tiff file `/usr/tmp/output.tif' failed: Permission denied
It works when I only read the file:
docker run --rm -v /home/userxyz/projects/data:/usr/tmp userxyz/test gdalinfo /usr/tmp/input.tif
Any idea what could be wrong with the writing permissions?
EDIT: when opening the data folder to read/write for "Others", the file is correctly created by user#500100
, so I guess it's something with username attribution? How can I do so that the file is created by userxyz
and not user#500100
?