Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

docker-compose: max depth exceeded

I was using docker-compose, but when I tried to build it again, this error shows, I have build this docker-compose multiple times:

ERROR: Service 'api' failed to build: max depth exceeded

I tried to execute docker system prune to clean my containers, but it didn't work.

docker-compose.yml

version: "3"
services:
    client:
        container_name: my_client
        image: mhart/alpine-node:12
        build: ./client      
        restart: always
        ports:
            - "3000:3000"
        working_dir: /client
        volumes:
            - ./client:/client
        entrypoint: ["npm", "start"]
        links:
            - api
        networks: 
            - my_network
    api:
        container_name: my_api
        build: ./api
        restart: always
        ports:
            - "9000:9000"
        environment:
            DB_HOSTNAME: mysql    
        working_dir: /api
        volumes:
            - ./api:/api
        depends_on: 
            - mysql
        networks:
            - my_network
    mysql:
        container_name: my_mysql
        build: ./db
        restart: always
        volumes:
            - /var/lib/mysql
            - ./db:/db
        ports:
            - "3307:3306"
        environment:
            - MYSQL_ROOT_PASSWORD=n 
            - MYSQL_USER=n
            - MYSQL_PASSWORD=n
            - MYSQL_DATABASE=n
        networks: 
            - my_network
        command: '--default-authentication-plugin=mysql_native_password'
networks:
    my_network:
        driver: bridge

this is the Dockerfile:

FROM mhart/alpine-node:12
WORKDIR /api
COPY package*.json /api/
RUN npm i -G nodemon
RUN npm install
COPY . /api/
EXPOSE 9000
CMD ["npm", "run", "dev"]

any help is appreciated.

like image 509
heliosk Avatar asked Aug 23 '26 16:08

heliosk


1 Answers

Max depth doesn't indicate an out-of-storage-capacity error (though a prune could accidentally fix it).

Rather it indicates that the api image that you were building had too many layers.

A plausible theory is that you have a recursion caused by having this in your compose file:

        image: mhart/alpine-node:12
        build: ./client      

and this in a Dockerfile

FROM mhart/alpine-node:12

(I'm assuming the Dockerfile in ./client is also FROM the same image).

Your build is essentially adding a few layers onto your local mhart/alpine-node:12 image every time you run it (you can confirm by running docker history mhart/alpine-node:12).

If so, you should probably rename the image in your compose file.

like image 59
Jedi Avatar answered Aug 26 '26 06:08

Jedi



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!