docker build . -t mookkiah/docker-webdavWithout external volume
docker run --detach --name webdav --publish 7000:8080 --env UID=0 mookkiah/docker-webdavWith external(host) volume
docker run --restart always --detach --name webdav --publish 7000:8080 \
--env UID=$UID --volume $PWD:/media mookkiah/docker-webdavOptionally you can add two environment variables to require HTTP basic authentication:
- WEBDAV_USERNAME
- WEBDAV_PASSWORD
docker run --restart always --detach --name webdav --publish 7000:8080 \
--env WEBDAV_USERNAME=webdav --env WEBDAV_PASSWORD=S0m37h1n6C0mp13x \
--env UID=$UID --volume $PWD:/media mookkiah/docker-webdavTo see the log
docker logs webdavTo get into the container
docker exec -it webdav /bin/sh
To see the list of a directory (ex: /media)
docker exec -it webdav ls -ltra /media
Store below file in file webdav.yaml and apply using kubectl apply -f webdav.yaml
# kubectl create deployment nginx-webdav --image=mookkiah/docker-webdav --dry-run -oyaml
apiVersion: apps/v1
kind: Deployment
metadata:
labels:
app: nginx-webdav
name: nginx-webdav
spec:
replicas: 1
selector:
matchLabels:
app: nginx-webdav
template:
metadata:
labels:
app: nginx-webdav
spec:
containers:
# Forcing specific version of image as it is from public and untrusted.
- image: mookkiah/docker-webdav
name: webdav
env:
- name: WEBDAV_USERNAME
value: "webdav"
- name: WEBDAV_PASSWORD
value: "S0m37h1n6C0mp13x" #SomethingComplex
- name: UID
value: "0" #String formatted UID of the file system directory /media (expect internal server error due to permission issue if not set right value)
---
# kubectl expose deployment nginx-webdav --type=LoadBalancer --name=webdav-service --port=8080 --dry-run -oyaml
apiVersion: v1
kind: Service
metadata:
labels:
app: nginx-webdav
name: webdav-service
spec:
ports:
- port: 8080
protocol: TCP
targetPort: 8080
selector:
app: nginx-webdav
type: LoadBalancer
To check access
curl http://localhost:7000
with authentication
curl -u webdav:S0m37h1n6C0mp13x http://localhost:7000
curl -X MKCOL -u webdav:S0m37h1n6C0mp13x http://localhost:7000/home/
curl -u webdav:S0m37h1n6C0mp13x -T README.md http://localhost:7000/README.md
curl -X DELETE -u webdav:S0m37h1n6C0mp13x http://localhost:7000/home/README.md
curl -X DELETE -u webdav:S0m37h1n6C0mp13x http://localhost:7000/home
Docker
docker stop webdav
docker rm webdavKubernetes
kubernetes delete -f webdav.yaml
If you get internal server error while making changes via webdav This normally happens when the UID parameter not given permission to access to the storage file system Try (only in development) execute below command to confirm if this is permission issue.
Docker
docker exec -it webdav chmod +777 /media -R
Kubernetes
kubectl exec -it <pod name> -- chmod +777 /media -R