Fuse mount in docker or docker-compose

Spread the love

FUSE is a Filesystem in Userspace that allows the creation of custom filesystems in userspace, such as cloud storage, NFS and etc. But for mount inside docker container need to add additional parameters to docker run command or inside docker-compose.yml file.

At first, you should have docker image with installed fuse package inside container. For allow mount inside container need to run docker run command with --cap-add SYS_ADMIN --device /dev/fuse:/dev/fuse --security-opt apparmor:unconfined

For docker-compose need to put inside docker-compose.yml file: 

cap_add:
  - SYS_ADMIN
devices:
  - /dev/fuse:/dev/fuse
security_opt:
  - apparmor:unconfined

Examples:

  • Docker: docker run -it --rm --cap-add SYS_ADMIN --device /dev/fuse:/dev/fuse --security-opt apparmor:unconfined
  • docker-compose.yml:
    version: '3'
    services:
    mycontainer:
      image: container_image:container_version
      cap_add:
        - SYS_ADMIN
      devices:
        - /dev/fuse:/dev/fuse
      security_opt:
        - apparmor:unconfined

 

Leave a Reply