trajano / docker-volume-plugins

Managed docker volume plugins
Eclipse Public License 2.0
143 stars 60 forks source link

subfolder option do not work #9

Closed svallier closed 6 years ago

svallier commented 6 years ago

i tried all of three methods to mount glusterfs volumes. None of them able to mount subdirectory in container.

the mountpoint seems correct : gluster-node1:volume/uploads 400G 475M 400G 1% /data/www/web

But the mountpoint did not mount the subdir but volume himself : root@c3bcdd1ea4cb:/data/www/web/# ls uploads

trajano commented 6 years ago

Can you show me what you did? Just mask out any sensitive information

svallier commented 6 years ago

Yes, thank you for your reply.

1- Plugin installation :
docker plugin install --alias glusterfs trajano/glusterfs-volume-plugin 2- Volume declaration in compose file :

volumes:
 nginx_logs:
    driver: glusterfs
    driver_opts:
      servers: lnx-gluster-node1,lnx-gluster-node2
    name: "myvol/logs/nginx"

3- volume mounting :

services:
  nginx:
    image: nginx:${IMAGE_TAG}
    build: ./angular/.
    depends_on:
      - php
    ports:
      - '8080:8080'
      - '80:80'
    volumes:
      - 'nginx_logs:/var/log/nginx'
    restart: on-failure

Then i start container. As you can see in docker inspect, the volume is correctly mounted on glusterfs volume subfolder :

         "Mounts": [
                {
                    "Type": "volume",
                    "Source": "nginx_logs/logs/nginx",
                    "Target": "/var/log/nginx",
                    "VolumeOptions": {
                        "Labels": {
                            "com.docker.stack.namespace": "myvol"
                        },
                        "DriverConfig": {
                            "Name": "glusterfs",
                            "Options": {
                                "servers": "lnx-gluster-node1,lnx-gluster-node2"
                            }
                        }
                    }
                }
            ],

Inside container, the source volume seems correct :

root@c9b5bef98041:/# df -h
Filesystem                                        Size  Used Avail Use% Mounted on
overlay                                           9.4G  5.3G  4.1G  57% /
tmpfs                                              64M     0   64M   0% /dev
tmpfs                                             4.0G     0  4.0G   0% /sys/fs/cgroup
/dev/mapper/vg_sys-lv_sys                         9.4G  5.3G  4.1G  57% /etc/hosts
shm                                                64M     0   64M   0% /dev/shm
lnx-gluster-node1:myvol/logs/nginx  400G  1.5G  399G   1% /var/log/nginx
tmpfs                                             4.0G     0  4.0G   0% /proc/acpi
tmpfs                                             4.0G     0  4.0G   0% /sys/firmware

but actually. The mountpoint is targeting the top of volume instead of subfolder :

root@c9b5bef98041:/# ls /var/log/nginx/
nginx_access.log nginx_error_log  logs
svallier commented 6 years ago

any idea ?

trajano commented 6 years ago

Just checking my setup. I use https://github.com/trajano/docker-volume-plugins/tree/master/glusterfs-volume-plugin#just-the-name on my home setup since it was the safest way for me to go.

volumes:
  nexus-data:
    driver: gluster:latest
    name: "trajano/nexus"

Checking my gluster server itself

[@store1 ~]$ ls /brick/
trajano
[@store1 ~]$ ls /brick/trajano/nexus/
backup  blobs  cache  db  elasticsearch  etc  generated-bundles  instances  javaprefs  keystores  lock  log  orient  restore-from-backup  tmp  upgrades

Now one key difference between the two of us is mine is just trajano/nexus which is one level but yours is myvol/logs/nginx which is two levels.

trajano commented 6 years ago

This part of the code looks right from what I can tell https://github.com/trajano/docker-volume-plugins/blob/master/glusterfs-volume-plugin/main.go#L68-L75 and that is the one that does the split

trajano commented 6 years ago

The unit tests pass so it's working the way I would expect it.

trajano commented 6 years ago

4.x of Gluster came out after I wrote this plugin, so I only tested with 3.13. If it is an issue because of 4.x then I would just update the documentation that says this is for 3.x series only.

trajano commented 6 years ago

Closing due to inactivity