Cannot upload files
I'm running idelsink/webdav from a docker-compose configuration on Docker for Windows (18.03.0-ce, build 0520e24).
docker-compose.yml:
version: '3'
services:
webdav:
image: idelsink/webdav
environment:
- USERNAME=webdav
- PASSWORD=vadbew
ports:
- '8081:80'
volumes:
- '.webdav:/webdav'
I'm using WinSCP (5.13.1, build 8265) to interact with the container. Using WinSCP, I can connect to http://localhost:8081 using webdav/vadbew, and can navigate the files and download them. However, when trying to upload a file to the directory, WinSCP fails, reporting 500 internal server error

I attached to the container and viewed the apache logs, and I see these lines:
[Mon Apr 09 20:10:19.385323 2018] [dav:error] [pid 18] [client 172.18.0.1:33560] The locks could not be queried for verification against a possible "If:" header. [500, #0]
[Mon Apr 09 20:10:19.385349 2018] [dav:error] [pid 18] [client 172.18.0.1:33560] Could not open the lock database. [500, #400]
[Mon Apr 09 20:10:19.385355 2018] [dav:error] [pid 18] (2)No such file or directory: [client 172.18.0.1:33560] Could not open property database. [500, #1]
Hmm thanks for the issue, I will have a look tomorrow when I have some time. I guess it has something to do with permissions of the lock file or something.
Hey, I've pushed something to a new branch with that feature: https://github.com/idelsink/webdav-docker/tree/upload-files#read-and-write-experimental
This enables the usage of an additional GID env variable to gain write access to the volume using Apache. Perhaps you can try it out?
Make sure that the folder to mount has the permission group write bit set. And the the APACHE_OPT_GID has the correct group id of the volumen that has write access. (you can get this with: id -g <username>)
I downloaded, built, and ran the experimental image. The good news is that it works as advertised. The bad news is that I have some reservations about this implementation, mostly due to me being a windows person.
-My intention was to use this as part of a docker-compose stack, and the dynamic nature of my user and group id makes this difficult. It turns out that docker-compose's configuration syntax doesn't allow running of script expressions, only resolution of environment variables. As such, providing my username and group id to the docker stack is more difficult than I'd like. I could set some environment variables and then reference them in my docker-compose configuration, but that's just too darn difficult.
- When running a container outside of
docker-compose, the
-e APACHE_UID=`id -u` -e APACHE_GID=`id -g`
syntax you specify doesn't work on PowerShell. Here's what I get when I run it:
docker run --rm -e USERNAME=webdav -e PASSWORD=vadbew -e APACHE_UID=`id -u` -e APACHE_GID=`id -g` -p 8080:80 -v /c/.webdav:/webdav idelsink/webdav:experimental
unknown shorthand flag: 'g' in -g`
- I'm not sure if it matters, but building the image on Windows means that Docker assumes some permissions, and it may affect the validity of my testing, since file permissions on the container may be different when built on *nix
You're probably right. Probably Windows has its own uid and gid commands. I don't reaally have a box to test this on...
Dirty hack would be to create a file with your user (from here on I will just assume that I have to explain this to a linux noob, just to make sure you know what to do; don't be insulted), start a simple docker container (docker run -it --rm -v c:/PATH/TO/DIR/ENCLOSING/FILE:/myfile alpine:latest) then list the attributes of the file (ls -l /myfile). That'll show you the UID and GID (3rd and 4th column) as seen by the docker container.
It seems rather hard to get your UID and GID in a generic way in a docker-compose file. So what I did now is hardcoded my ids and that seems to work quite well!
I had the same problem (same error logs), but came up with a different solution. I noticed that in the container, in file /etc/apache2/conf.d/dav.conf, there is a line to configure the lock file: DavLockDB /var/lib/dav/lockdb, but the directory /var/lib/dav doesn't exist.
After I created the directory, changed ownership to apache:apache and also changed the ownership of /webdav everything works.
In the end I created the following Dockerfile to get it all running. @idelsink, maybe you can integrate these commands in your scripts?
FROM idelsink/webdav
RUN mkdir /var/lib/dav
RUN chown -R apache:apache /var/lib/dav
RUN chown -R apache:apache /webdav
I had the same problem (same error logs), but came up with a different solution. I noticed that in the container, in file
/etc/apache2/conf.d/dav.conf, there is a line to configure the lock file:DavLockDB /var/lib/dav/lockdb, but the directory/var/lib/davdoesn't exist.After I created the directory, changed ownership to
apache:apacheand also changed the ownership of/webdaveverything works.In the end I created the following Dockerfile to get it all running. @idelsink, maybe you can integrate these commands in your scripts?
FROM idelsink/webdav RUN mkdir /var/lib/dav RUN chown -R apache:apache /var/lib/dav RUN chown -R apache:apache /webdav
Great work! It's working for me