Sign inSign up

juliohm/docker-webdav

By juliohm

Updated over 8 years ago

A configurable apache2 container you can use to serve files via webdav

Image
0

166

juliohm/docker-webdav repository overview

Docker-WebDAV

Github Repo: https://github.com/juliohm1978/docker-webdav

This docker image allows you to serve files using WebDAV. It is based FROM gcr.io/google-containers/ubuntu-slim:0.14, featuring a standard apache2 installation via apt packages.

For a quick demonstration, run:

docker run --rm -it --name docker-webdav \
  -v /path/to/shared/dir:/media \
  juliohm/docker-webdav:1.0

That will container will share the contents of /path/to/shared/dir to any WebDAV client without restictions or protections.

Customizing

That quick-start example will most likely not allow any files to be written or deleted by the client. Without further configuration, the Apache instance inside the container runs with its default installation user/group www-data.www-data. Since this user has uid=33 and gid=33, the shared directory /path/to/shared/dir will likely not have the same owner.

In a common scenario, changing user permissions on the shared directory will NOT be an option. In order to gain write permissions inside the container, you will need to pass the host's uid/gid that owns the files in the shared directory. You can do that by changing the user/group that Apache uses to spawn its worker processes.

Changing the runtime user of Apache workers

To change the runtime user of Apache workers, simply set APACHE_USERID and APACHE_GROUPID to whatever UID and GID match the file permssions in your shared directory.

docker run --rm -it --name docker-webdav \
  -e APACHE_USERID=$(id -u $USER) \
  -e APACHE_GROUPID=$(id -g $USER) \
  -v /path/to/shared/dir:/media \
  juliohm/docker-webdav:1.0

REMEMBER: Whatever users and groups you have on your host, those will not have the same name inside the container. Because of that, you will not be able to pass them by name. You need to specify their uid/gid numbers. In any standard Linux distribution, you can find uid/gid numbers for any user with the following:

id -u myuser
id -g myuser

When these values are passed as environment variables, internally the container will create a new user for itself www using the provided uid/gid and configure Apache workers to run as that user.

Both APACHE_USERID and APACHE_GROUPID are optional.

Defining username and password

This image also allows you to define a username and password to protect the contents of the shared directory. Whenever WEBDAV_USERNAME and WEBDAV_PASSWORD are defined, the container will create the necessary Basic Authentication files and configure Apache to use those credentials.

docker run --rm -it --name docker-webdav \
  -e APACHE_USERID=$(id -u $USER) \
  -e APACHE_GROUPID=$(id -g $USER) \
  -e WEBDAV_USERNAME=myuser \
  -e WEBDAV_PASSWORD=mysecret \
  -v /path/to/shared/dir:/media \
  juliohm/docker-webdav:1.0

For authentication, both WEBDAV_PASSWORD and WEBDAV_USERNAME need to be specified. If either is missing, no authencitation will be configured.

Tag summary

Content type

Image

Digest

Size

73 MB

Last updated

over 8 years ago

docker pull juliohm/docker-webdav:1.0