User Tools

Site Tools


Use Hetzner storage box as docker volume

First create the directory on the share e.g. dock_vol

mkdir /mnt/backup/dock_vol

Create volume with cifs driver

docker volume create \
	--driver local \
	--opt type=cifs \
	--opt device=// \
	--opt,iocharset=utf8,rw,username=uxxxxxx,password=xxxxxxxxxx,file_mode=0660,dir_mode=0660 \
	--name cifs_volume

This is enough, you don't need to mount the share on host as well.

If the app running in container is running and trying to write as a different user than root, you will need to adjust the permissions in above command that creates volumes to …file_mode=0777,dir_mode=0777…, as per this example.

Ansible playbook task example:

- hosts: "myhost"
    - name: Create docker volume on shared storagebox
        name: cifs_volume
          type: cifs
          device:  "device=//"
          o: ",iocharset=utf8,rw,username=uxxxxxx,password=xxxxxxxxxx,file_mode=0660,dir_mode=0660"
      tags: volume

Test example

docker run -d \
  --name=nginxtest \
  -v cifs_volume:/usr/share/nginx/html \

Tested on

  • Docker 23.0.1
  • ansible 2.9.27

See also


wiki/use_hetzner_storage_box_docker_volume.txt · Last modified: 2023/06/19 15:02 by antisa

Except where otherwise noted, content on this wiki is licensed under the following license: CC0 1.0 Universal
CC0 1.0 Universal Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki