Docker compose can't map directory on under the root

Hello everyone, I installed docker pre-installed on Ubuntu 24 system.I want to use docker to load nas-tools and Jellyfin to build a nas.BUT,When I want to map a folder, I find that the folder mapping in the root directory will fail, but the folder mapping in the home directory will succeed.for example:

services:
  nas-tools:
    image: hsuyelin/nas-tools:latest
    ports:
      - 3000:3000 
    volumes:
      - /home/admin//docker-compose/nas-tools:/config 
      - /home/admin/video:/video
    environment: 
      - user=root
      - UMASK=000 

will work good.but:

services:
  nas-tools:
    image: hsuyelin/nas-tools:latest
    ports:
      - 3000:3000 
    volumes:
      - /home/admin/docker-compose/nas-tools:/config 
      - /data1/video:/video
    environment: 
      - user=root
      - UMASK=000 

will failedļ¼Œ /data is a folder mounted on another diskI canā€™t read or write any file in /data1/video by docker volumes.
This is really bothering me. Can someone help me?

We usually need the following information to understand the issue:

  1. How did you install Docker? Sharing the platform almost answers it, but only almost. Direct links to the followed guide can be useful.

  2. On debian based Linux, the following commands can give us some idea and recognize incorrectly installed Docker:

    docker info
    docker version
    

    Review the output before sharing and remove confidential data if any appears (public IP for example)

    dpkg -l | grep docker
    snap list docker
    

When you share the outputs, always format your posts according to the following guide: How to format your forum posts

Thanks,meyay.I have installed docker when Install Ubuntu 24,here is my outoput info:

  1. my docker info output:
Client:
 Version:    24.0.5
 Context:    default
 Debug Mode: false
 Plugins:
  buildx: Docker Buildx (Docker Inc.)
    Version:  v0.11.2
    Path:     /usr/libexec/docker/cli-plugins/docker-buildx
  compose: Docker Compose (Docker Inc.)
    Version:  v2.20.3
    Path:     /usr/libexec/docker/cli-plugins/docker-compose

Server:
 Containers: 4
  Running: 4
  Paused: 0
  Stopped: 0
 Images: 5
 Server Version: 24.0.5
 Storage Driver: overlay2
  Backing Filesystem: extfs
  Supports d_type: true
  Using metacopy: false
  Native Overlay Diff: true
  userxattr: false
 Logging Driver: json-file
 Cgroup Driver: systemd
 Cgroup Version: 2
 Plugins:
  Volume: local
  Network: bridge host ipvlan macvlan null overlay
  Log: awslogs fluentd gcplogs gelf journald json-file local logentries splunk syslog
 Swarm: inactive
 Runtimes: io.containerd.runc.v2 runc
 Default Runtime: runc
 Init Binary: docker-init
 containerd version: 3dce8eb055cbb6872793272b4f20ed16117344f8
 runc version:
 init version: de40ad0
 Security Options:
  apparmor
  seccomp
   Profile: builtin
  cgroupns
 Kernel Version: 6.8.0-31-generic
 Operating System: Ubuntu Core 22
 OSType: linux
 Architecture: x86_64
 CPUs: 3
 Total Memory: 7.261GiB
 Name: nas
 ID: 71b3aa9d-b336-4c59-8ae7-dac13dd522a1
 Docker Root Dir: /var/snap/docker/common/var-lib-docker
 Debug Mode: false
 Experimental: false
 Insecure Registries:
  127.0.0.0/8
 Live Restore Enabled: false
  1. my docker version output:
Client:
 Version:           24.0.5
 API version:       1.43
 Go version:        go1.20.8
 Git commit:        ced0996
 Built:             Sat Oct  7 00:14:00 2023
 OS/Arch:           linux/amd64
 Context:           default

Server:
 Engine:
  Version:          24.0.5
  API version:      1.43 (minimum version 1.12)
  Go version:       go1.20.8
  Git commit:       a61e2b4
  Built:            Sat Oct  7 00:14:30 2023
  OS/Arch:          linux/amd64
  Experimental:     false
 containerd:
  Version:          v1.6.21
  GitCommit:        3dce8eb055cbb6872793272b4f20ed16117344f8
 runc:
  Version:          1.1.7
  GitCommit:
 docker-init:
  Version:          0.19.0
  GitCommit:        de40ad0
  1. My dpkg -l | grep docker output is NULL

  2. My snap list docker output is:

Name    Version  Rev   Tracking       Publisher   Notes
docker  24.0.5   2915  latest/stable  canonicalāœ“  -

Uninstall that and install Docker from the official documentation

The snap version is a docker deamon in a container. You canā€™t mount everything.

1 Like

To extend on the response of @rimelek: the snap package is not vanilla docker and does not behave like vanilla docker in every way.

The observed restriction is a design choice of the snap package maintainer:

If you want to replace it with vanilla docker-ce from Dockerā€™s repositories, you need to uninstall the snap package first:

sudo snap remove --purge docker

And then install it according to the link @rimelek shared.

2 Likes

Thanks!when uninstall sanp docker and reinstall the docker by apt,it can map root directory!