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
.
docker-compose.yaml
specifies that your app in the container is running on port 4200, but yournginx-custom.conf
listens on port 80. Those ports should match. – Kemp