6

Someone suggested on SO to post here. Reposting from https://stackoverflow.com/questions/59024392/too-many-links-in-var-lib-docker-error-while-building-docker-container


Trying to run docker-compose build and getting the following error:

ERROR: ... evalSymlinksInScope: too many links in /var/lib/docker/overlay2/a476d12eaac1c1e3cc684c992cf829b61b999959fd7d23d5a27120dbfd43e178/merged/opt/api/resources

I searched online and have tried running the following commands, but nothing works:

docker network prune
docker images prune
docker system prune -a --volumes

If I run ln -ls /var/lib, there is nothing in this folder about /docker. Is this referring to the Docker container? If so, how can this be, when I am in the process of building it. Any ideas on how to resolve this would be great, thank you.

thehme
  • 161

3 Answers3

4

Had the same issue, I fixed it going to

Docker -> Troubleshoot -> Reset to factory defaults

Warning: All containers and volumes will be deleted

1

The error "too many links" usually means that there is a symbolic link pointing to itself, and is not specific to docker.

To find out what happens, use the namei command, usually part of util-linux.

namei /var/lib/docker/overlay2/a476d12eaac1c1e3cc684c992cf829b61b999959fd7d23d5a27120dbfd43e178/merged/opt/api/resources

You should see output similar to this, with an indication about too many link levels somewhere in the path.

f: /var/lib/docker/overlay2/a476d12eaac1c1e3cc684c992cf829b61b999959fd7d23d5a27120dbfd43e178/merged/opt/api/resources
 d /
 d var
 d lib
 ...
RalfFriedl
  • 8,981
  • Thanks @RalfFriedl. I think this namei command in not available on Macs, right?I installed it using brew, but I only see messages about the missing docker directory, i.e. ERROR on file docker No such file or directory (2). I was building this container just hours before it happened and the code changes I made were not related to the Docker config/files. If I am building the Docker container, then there is no container to ssh into to look around, so I am confused as to where these links are. – thehme Nov 25 '19 at 13:27
  • If /var/lib/docker doesn't exist, then there can't be an error about too many links. Maybe your docker environment or the shell you use to investigate use different roots/containers? – RalfFriedl Nov 25 '19 at 17:38
0

I was trying to deploy a nodejs app via docker-compose from windows to a debian VPS using --context and got the same issue with apparently no reason

I tried all of the solutions above, clear both images cache and build cache and still nothing worked, Then I figured out that my desktop version of docker was upgraded automatically, so I decided to upgrade docker in my VPS too and everything ran smoothly.

So I guess it's because something with the docker internal building process changed, something regarding to storage driver, and that caused breaking changes between versions but I'm not sure. I hope this can at least help to find a more specific solution.

Here the guide I followed to upgrade docker in a debian https://docs.wavemaker.com/learn/on-premise/upgrade/docker-upgrade/