Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Docker-compose hangs on Attaching to

I have an issue when running docker-compose up. It hangs on attaching to and I cannot access my web app on localhost:4200.

docker-compose.yml:

version: '2' # specify docker-compose version  # Define the services/containers to be run services:   angular: # name of the first service     build:       context: .        dockerfile: ./.docker/scs.dockerfile  # specify the directory of the Dockerfile     container_name: secure-cloud-storage-build-dev     image: secure-cloud-storage     ports:       - "4200:4200" # specify port forwarding 

dockerfile:

# Stage 0, based on Node.js, to build and compile Angular FROM node:8.6 as node WORKDIR /app COPY package.json /app/ RUN npm install COPY ./ /app/ ARG env=prod RUN npm run build -- --prod --environment $env  # Stage 1, based on Nginx, to have only the compiled app, ready for production with Nginx FROM nginx:1.13 COPY --from=node /app/dist/ /usr/share/nginx/html COPY ./nginx-custom.conf /etc/nginx/conf.d/default.conf 

nginx-custom.conf:

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

Here is verbose output:

docker-compose --verbose up output

Any clues what might be going wrong? I am quite fresh in Docker world, basically doing tutorials, so might be something obvious i missed. My localhost:4200 returns ERR_EMPTY_RESPONSE.

like image 374
PerlMonk92 Avatar asked May 01 '18 18:05

PerlMonk92


2 Answers

I know that I'm late to the party but this is to be expected. docker-compose up, just like docker run, requires a -d flag if you want to get your command line back.

Here is what the command would look like: docker-compose up -d

As far as why your app is returning an empty response I'm not sure.

Hope this helps others coming to this thread!

like image 99
AJRohrer Avatar answered Sep 21 '22 16:09

AJRohrer


In my case docker also hangs showing the "Attaching to ..." message, but the application works. So it seems to be a display issue that you can ignore.

You can run docker in detached mode docker-compose up -d angular to suppress this message. Till now I did not figure out how to run it in foreground mode without receiving the message.

Your configuration files in general look ok, but you have to configure the right ports i.e. nginx also needs to listen on port 4200.

like image 21
Martin Avatar answered Sep 21 '22 16:09

Martin