Docker - max depth exceeded

Viewed 26606

So I am using this example:

https://github.com/mcmoe/mssqldocker

In order to create a SQL Server image and load it with data. I have several sql scripts which I run when I run the container.

However, I started getting this error when building the image:

Step 7/9 : ENTRYPOINT ./entrypoint.sh
 ---> Running in c8c654f6a630
max depth exceeded

I'm not sure how to fix this, I restarted docker and even updated it. I read something about 125 layers? Can anyone explain the cause of this and a potential fix?

I found this command to run:

docker history microsoft/mssql-server-linux:latest | wc -l
 312

My docker-compose yml:

version: "3"
services:
  mssql:
      build: .
      image: 'microsoft/mssql-server-linux'
      ports:
          - '1433:1433'
      environment:
          - ACCEPT_EULA=Y
          - SA_PASSWORD=Abcgfgh123!
      volumes:
          - db_volume:/var/lib/mssql/data
volumes:
  db_volume:
5 Answers

The image parameter for a service in a docker-compose.yml definition has dual meanings depending on the existence of a build parameter.

  • If there is no build stanza, The image will just be pulled and run.

  • If you have a build stanza, image will be the name your built image is tagged as, and run.

By naming the built image microsoft/mssql-server-linux, which is the same as the FROM microsoft/mssql-server-linux image. Docker was layering the build on top of itself each time.

The original build started on the "official" microsoft/mssql-server-linux but then each subsequent build would start from your local microsoft/mssql-server-linux image which had been appended to, until eventually you hit the maximum number of layers for your storage driver.

Use your own namespace for all images you build:

version: "3"
services:
  mssql:
      build: .
      image: 'user3437721/mssql-server-linux'

Delete all local docker images related to your dockerfile using the following and try again.

$ docker rmi -f $(docker images -a -q)

I was already using a custom image name like in the accepted answer, and I still had this issue.

In order to get past this error, I found that I needed to remove all unused (not associated with any container) and dangling (old image after a new one is made) docker images with the following command:

docker image prune -a

See https://linuxhandbook.com/remove-docker-images/

If this error pops for specific images, then you might want to take a look at the number of layers that exist in your said docker image. When doing changes to a Docker image, each change is getting added as a layer regardless the size increase in the image. I have come across scenarios where my docker images having multiple layers and failing to push in Jenkins jobs. The workaround is to use the same context in the docker image but with reduced amount of layers. For that you can simply take out the content of the image and port them into a new image with a new image name, which will result the same content in a new image and with less amount of layers. Use this tip across scenarios that is helpful. Thanks

for my situation the error was due to \r. I am running windows host and the linux image needs to run an script file for entrypoint which is copied from windows to docker image. during this process the script end lines were changed from \n to \r\n which resulted in this error. undoing this made the error go away.

Related