docker-compose up stuck on attaching to

10,249

Solution 1

In my case was a port forwarding at the docker-compose.yml. I was doing the forward to 8080 when the exposed port was the 80 so when I've changed the port forwarding to 80 at the docker-compose.yml the service have done as should be.

Obs.: Not enough reputation to post a comment so I did it here. Sorry guys :)

Solution 2

First check if the container is up. You can do this by running:

docker-compose ps

In case of your configuration I got:

         Name                   Command          State               Ports             
---------------------------------------------------------------------------------------
54368216_idcheck-demo_1   nginx -g daemon off;   Up      80/tcp, 0.0.0.0:8080->8080/tcp

as you can see container is running with nginx not being daemonized which explains why the console is hanging after you run docker-compose up.

You can also run a quick telnet to see if the HTTP service is responding correctly:

telnet localhost 8080
Trying ::1...
Connected to localhost.
Escape character is '^]'.

Bottom line is that console stuck on "Attaching to..." is caused by the nginx process not running as a daemon.

You can put the container into background running:

docker-compose up -d

Solution 3

I got this problem when I start nginx using "docker-compose up". And the reason is Port Conflict, so I fix it by changing Ports Configuration.

Share:
10,249
Kay
Author by

Kay

Updated on July 25, 2022

Comments

  • Kay
    Kay almost 2 years

    Im trying to dockerize my react app.

    Whenever i run docker-compose up it gets stuck on "Attaching to"

    Dockerfile

    # Stage 0 - Pre-requisite: Based On Node.js to BUILD and compile App.
    
    FROM node:10.15.0-alpine as node
    
    WORKDIR /app
    
    COPY package.json /app/
    
    RUN npm install 
    
    COPY ./ /app/
    
    RUN npm run build
    
    # Stage 1 - Based On Nginx to have ONLY a compiled and PRODUCTION ready build.
    
    FROM nginx:1.15.8-alpine
    
    COPY --from=node /app/build/ /usr/share/nginx/html
    
    COPY ./nginx-custom.conf /etc/nginx/conf.d/default.conf
    

    docker-compose.yml

    version: '3'
    
    services:
      idcheck-demo:
        image: idcheck-demo
        build:
          context: .
          dockerfile: Dockerfile
        ports:
          - 8080:8080
    

    nginx-custom.conf

    server {
        listen 8080;
        location / {
            root /usr/share/nginx/html;
            index index.html index.htm;
            try_files $uri $uri/ /index.html =404;
        }
    }
    

    Ive tried attempting to access it by going to 0.0.0.0:8080 but it just returns me with the following error in the browser

    This page isn’t working 0.0.0.0 didn’t send any data. ERR_EMPTY_RESPONSE

  • Kay
    Kay over 5 years
    How do i fix that?
  • dongi
    dongi over 5 years
    docker-compose up -d will put the container into background
  • Kay
    Kay over 5 years
    This did not solve my problem, i solved it by adding configuration in my nginx to turn of daemon
  • dongi
    dongi over 5 years
    doesn't this cause your container to stop?
  • flik
    flik over 5 years
    It is does not solve the issue. I cannot see logs container and It is not yet fully up and not accessible server in browser even it is showing running.
  • JeromeDL30
    JeromeDL30 about 4 years
    This also happened to me and what I did was expose the port of nginx and used docker compose up -d