I'm tying to run an Angular app via Docker for development. I want the app to live-reload in the Docker container every time changes are made in the host - just as it would if i ran 'ng serve' on the host machine.
I've managed to run the Angular app in a Docker container but i'm unable to access the app from the host. I am able to access other apps from other containers without any problem. It's the first time i'm using Angular with Docker and for some reason things aren't going as expected.
Here are my settings:
.env:
PROJECT_NAME=angular_proj
CMS_IMAGE=node:8.16.0-alpine
Dockerfile:
ARG CMS_IMAGE
FROM ${CMS_IMAGE} AS node
ARG PROJECT_NAME
RUN mkdir -p /srv/www/${PROJECT_NAME}/cms
WORKDIR /srv/www/${PROJECT_NAME}/cms
COPY /cms/package*.json ./
RUN npm install
COPY /cms ./
EXPOSE 4200/tcp
RUN npm start #executes 'ng serve --host 0.0.0.0'
docker-compose.yml:
version: '3.7'
services:
cms:
container_name: ${PROJECT_NAME}_cms
build:
context: .
dockerfile: .docker/cms/Dockerfile
args:
CMS_IMAGE: ${CMS_IMAGE}
PROJECT_NAME: ${PROJECT_NAME}
ports:
- 4200:4200
volumes:
- ./cms:/srv/www/${PROJECT_NAME}/cms
When i start the container everything runs as expected:
** Angular Live Development Server is listening on 0.0.0.0:4200, open your browser on http://localhost:4200/ **
But when i try to open the app from the host i get ERR_CONNECTION_REFUSED. I searched for similar threads and tried most of their solutions, but without any success. What am I doing wrong?
I'm running MacOS Mojave with Docker 2.0.0.3 (31259).