Docker Community Forums

Share and learn in the Docker community.

Docker compose running forever

Hey,

I just started learnig docker and i am trying to make a container for one of my projects. The problem that i am facing is that apt-get install inside my Dockerfile wont finish. I waited up to 20 mins and still didnt finish and since its a non interactive process i cant see what’s happening.

I am using Docker version 20.10.5, build 55c4c88 on Windows 10 Pro 64bit. Tried with both wsl2 backend and hyper-v.

There are my files:
Dockerfile

FROM ubuntu:18.04 

RUN apt-get update && apt-get install -y \

    curl \

    mc \

    nano \

    dialog \

    sudo \

    apache2 \

    php7.2 \

    && rm -rf /var/lib/apt/lists/*

ADD entrypoint.sh /usr/bin/entrypoint.sh

RUN chmod a+x /usr/bin/entrypoint.sh

ENTRYPOINT [ "entrypoint.sh" ]

docker-compose.yaml

version: "3.1"

services:

    www:

        build: .

        ports: 

            - "80:80"

        volumes:

            - .:/var/www/workbuzz/

        links:

            - db

        networks:

            - default

    db:

        image: mariadb

        ports: 

            - "3306:3306"

        command: --default-authentication-plugin=mysql_native_password

        environment:

            MYSQL_DATABASE: workbuzzdev

            MYSQL_USER: buzz

            MYSQL_PASSWORD: test

            MYSQL_ROOT_PASSWORD: test

        volumes:

            - ./migration:/docker-entrypoint-initdb.d

            - ./conf:/etc/mysql/conf.d

            - persistent:/var/lib/mysql

        networks:

            - default

volumes:

    persistent:

entrypoint.sh

#!/bin/bash

service apache2 start

tail -F -n0 /etc/hosts

After running docker-compose up -d the whole process runs forever when docker hits the part with the apt-get install. If i remove the php7.2 part then it will finish but still after around 5 minutes what in my oppinion is not normal. I suppose i am doing something wrong but please note that since i am just learning all this, the code posted is scavanged from multiple sources but its working. If i exclude the php7.2 part then the build finishes after around 5 minutes and everything boots up normally.

Any advice on how to speed up the build process would be most welcome.
Regards,
Trix

Solved the problem, the hanging was cause by tzdata asking for timezone. I ran docker build and in that case you can see the commands and what is happening and this way i could debug it.

You can use tty configuration option.

version: ‘3’

services:
app:
image: node:8
tty: true # ← This option

Note: If you use Dockerfile for image and CMD in Dockerfile, this option won’t work; however, you can use the entrypoint option in the compose file which clears the CMD from the Dockerfile.