Filesystem actions in containers fail with `Too many levels of symbolic links`

This document (000020104) is provided subject to the disclaimer at the end of this document.

Situation

Issue

When attempting to perform a filesystem action inside a container with a volume located on an autofs directory, the error Too many levels of symbolic links is thrown and the action fails.

bash: cd: /data: Too many levels of symbolic links

Pre-requisites

  • Docker container or Kubernetes Pod with a volume defined that is mounted on the host with autofs, typically backed by NFS

Root cause

As the share that backs the autofs volume isn't mounted until the directory specified is accessed, it is typically not mounted when a container is run.
With the default Docker bind-mount propagation of rprivate, containers do not receive mount changes for volumes from the host.

Resolution

Docker - Mount the volume in question with the flag slave, rslave, shared, or rshared to ensure that mount changes are propagated to the container.
Example:
docker run -d -v /path/to/autofs:/data:shared ubuntu

See the links at the bottom of this article for info on what each of these flags does

Kubernetes - Define mountPropagation for the volume in question as either HostToContainer (same as Docker's rslave) or Bidirectional (same as Docker's rshared):

kind: Pod
apiVersion: v1
metadata:
  name: test-app
spec:
  containers:
    - name: test
      image: busybox
      volumeMounts:
      - mountPath: "/data"
        name: test-app-vol
        mountPropagation: HostToContainer
  volumes:
    - name: test-app-vol
      hostPath:
        path: /data

Further reading

Docker bind propagation - https://docs.docker.com/storage/bind-mounts/#configure-bind-propagation
Kubernetes mountPropagation - https://kubernetes.io/docs/concepts/storage/volumes/#mount-propagation
Linux Kernel Shared Subtree - https://www.kernel.org/doc/Documentation/filesystems/sharedsubtree.txt

Disclaimer

This Support Knowledgebase provides a valuable tool for SUSE customers and parties interested in our products and solutions to acquire information, ideas and learn from one another. Materials are provided for informational, personal or non-commercial use within your organization and are presented "AS IS" WITHOUT WARRANTY OF ANY KIND.

  • Document ID:000020104
  • Creation Date: 09-Jul-2021
  • Modified Date:09-Jul-2021
    • SUSE Rancher

< Back to Support Search

For questions or concerns with the SUSE Knowledgebase please contact: tidfeedback[at]suse.com

SUSE Support Forums

Get your questions answered by experienced Sys Ops or interact with other SUSE community experts.

Join Our Community

Support Resources

Learn how to get the most from the technical support you receive with your SUSE Subscription, Premium Support, Academic Program, or Partner Program.


SUSE Customer Support Quick Reference Guide SUSE Technical Support Handbook Update Advisories
Support FAQ

Open an Incident

Open an incident with SUSE Technical Support, manage your subscriptions, download patches, or manage user access.

Go to Customer Center