Autofs in docker for mac

I wonder if it is possible to use automounter/autofs for nfs-purposes in a docker-container on docker for mac.
Mounting NFS-shares is working well, but autofs itself does not work for me.

I tried the stuff from https://whyistheinternetbroken.wordpress.com/2015/05/12/techusing-nfs-with-docker-where-does-it-fit-in/ but at the end it fails with the error:

Sep 18 13:37:00 6ab5838b7cea systemd[1]: Starting Automounts filesystems on demand…
Sep 18 13:37:00 6ab5838b7cea automount[286]: /usr/sbin/automount: test mount forbidden or incorrect kernel protocol version, kernel protocol version 5.00 or above required.

The docker-container is started in --privileged mode.

In https://scriptthe.net/2015/02/05/autofs-in-docker-containers/ it is mentioned that “modprobe autofs4” needs to run at the host first. Is this possible on docker for mac? Does anybody have a working docker-container with autofs on docker for mac?

1 Like

I am having the same issue. Has anyone found a solution for this?

Hard to believe that you have the same problem, because the original question was 6 years ago and Docker Desktop probably changed a lot since then. The current kernel in the VM is 5.10, so it should not be the problem, however I don’t know what the current requirement is. Please, share more information about your issue. Exact error message and what you tried so far. What is your mac version and your Docker and Docker Desktop version.

I can’t guarantee that you will get an answer, but you will have better chance. I have never tried NFS in Docker Desktop for Mac, not to mention autofs.

Akos,

Thanks for the reply. Oddly, I am using the latest version of docker on the latest version of macOS (12.5.1 - Monterey)

docker version
Client:
 Cloud integration: v1.0.28
 Version:           20.10.17
 API version:       1.41
 Go version:        go1.17.11
 Git commit:        100c701
 Built:             Mon Jun  6 23:04:45 2022
 OS/Arch:           darwin/amd64
 Context:           default
 Experimental:      true

Server: Docker Desktop 4.11.1 (84025)
 Engine:
  Version:          20.10.17
  API version:      1.41 (minimum version 1.12)
  Go version:       go1.17.11
  Git commit:       a89b842
  Built:            Mon Jun  6 23:01:23 2022
  OS/Arch:          linux/amd64
  Experimental:     true
 containerd:
  Version:          1.6.6
  GitCommit:        10c12954828e7c7c9b6e0ea9b0c02b01407d3ae1
 runc:
  Version:          1.1.2
  GitCommit:        v1.1.2-0-ga916309
 docker-init:
  Version:          0.19.0
  GitCommit:        de40ad0

When I run automount with strace, I get a bit more information and it looks like it’s failing to test mount??

mount("automount", "/tmp/autolZdOE5", "autofs", MS_MGC_VAL, "fd=4,pgrp=458,minproto=3,maxprot"...) = -1 ENODEV (No such device)

I am not sure what it means by “No such device”, but maybe it’s failing to find autofs module?

In fact, I get this message when I try to load autofs

root@ad844c23df5f:/tmp# modprobe autofs
modprobe: FATAL: Module autofs not found in directory /lib/modules/5.10.104-linuxkit

Maybe macOS doesn’t provide autofs module with the version of the linux kernel that it provides?

Here is the (almost) full output.

$ strace automount --debug
mmap(NULL, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7fe34894a000
mprotect(0x7fe34b108000, 8192, PROT_READ) = 0
prlimit64(0, RLIMIT_STACK, NULL, {rlim_cur=8192*1024, rlim_max=RLIM64_INFINITY}) = 0
munmap(0x7fe34b0ca000, 13299)           = 0
getrandom("\x8a\x34\x94\xc1\x72\x9f\xd2\x00", 8, GRND_NONBLOCK) = 8
brk(NULL)                               = 0x55f714883000
brk(0x55f7148a4000)                     = 0x55f7148a4000
rt_sigprocmask(SIG_BLOCK, ~[ILL TRAP ABRT BUS FPE SEGV RTMIN RT_1], NULL, 8) = 0
openat(AT_FDCWD, "/etc/autofs.conf", O_RDONLY|O_CLOEXEC) = 3
fcntl(3, F_GETFD)                       = 0x1 (flags FD_CLOEXEC)
openat(AT_FDCWD, "/etc/default/autofs", O_RDONLY|O_CLOEXEC) = 4
newfstatat(3, "", {st_mode=S_IFREG|0644, st_size=15685, ...}, AT_EMPTY_PATH) = 0
uname({sysname="Linux", nodename="ad844c23df5f", ...}) = 0
newfstatat(3, "", {st_mode=S_IFREG|0644, st_size=15685, ...}, AT_EMPTY_PATH) = 0
read(3, "#\n# Define default options for a"..., 4096) = 4096
read(3, "\t\tMultiple entries can be given "..., 4096) = 4096
read(3, "val_udp, nfs_retry_interval_tcp,"..., 4096) = 4096
read(3, "\n#\tIt is empty by default.\n#\n# s"..., 4096) = 3397
read(3, "", 4096)                       = 0
newfstatat(4, "", {st_mode=S_IFREG|0644, st_size=339, ...}, AT_EMPTY_PATH) = 0
read(4, "#\n# Init system options\n#\n# If t"..., 4096) = 339
read(4, "", 4096)                       = 0
close(3)                                = 0
close(4)                                = 0
uname({sysname="Linux", nodename="ad844c23df5f", ...}) = 0
geteuid()                               = 0
getpgrp()                               = 458
mkdir("/tmp/autolZdOE5", 0700)          = 0
pipe2([3, 4], 0)                        = 0
mount("automount", "/tmp/autolZdOE5", "autofs", MS_MGC_VAL, "fd=4,pgrp=458,minproto=3,maxprot"...) = -1 ENODEV (No such device)
close(3)                                = 0
close(4)                                = 0
rmdir("/tmp/autolZdOE5")                = 0
write(2, "automount: test mount forbidden "..., 118automount: test mount forbidden or incorrect kernel protocol version, kernel protocol version 5.00 or above required.
) = 118
exit_group(1)                           = ?
+++ exited with 1 +++

It looks like I am very good at being wrong recently :slight_smile: I thought the error message meant that the kernel version was old, but it actually says “kernel protocol version” not “kernel version”, so you might have the same error as the OP had after all.

Not macOS, but Docker Desktop or LinuxKit behind it. I don’t know LinuxKit enough to tell.

It was helpful :slight_smile:

Yes, the VM does not have autofs module. Even if it had, I don’t think it would be a good idea to change the kernel module settings inside the VM. Maybe I am wrong, but Docker created the VM and can support Docker Desktop until we start to change it. If we enable or disable modules, that can cause problems.

I don’t have any use case that would require autofs, but if you realy need it, you can try to ask for it here:

I would try the first link, because I am not completely sure that it requires a new feature, but it is likely.

If you can work without autofs, you can still use Docker Desktop. If you can’t, then you can still use multipass to run an ubuntu VM with Docker and Portainer installed in it. Then you can configure Linux as you whish.

brew install --cask multipass
multipass launch --name docker-vm docker
multipass shell docker-vm

Akos,

Thanks for the update. I’ve requested docker/for-mac to make this module available.

docker for-mac doesn't support autofs module · Issue #6463 · docker/for-mac · GitHub