I'm trying to run an angular app inside a docker container. The docker container exits shortly after the command "ng serve --host 0.0.0.0" is executed.
docker-compose.yml:
services
frontend:
build:
context: .
dockerfile: ./docker/Dockerfile-frontend
command: sh -c "cd public; npm install && npm run start"
container_name: frontend-mol
environment:
- PORT=4200
networks:
- fullstack
ports:
- 4200:4200
volumes:
- ./:/app
working_dir: /app
networks:
fullstack:
driver: bridge
package.json:
"scripts" : {
"start": "ng serve --host 0.0.0.0"
}
I did not alter the angular.json file. This is a fresh installation of Angular 17, I'm just trying to make a "hello world" app running in the container. What am I missing here?
Logs:
2024-05-20 12:38:04 > public@0.0.0 start
2024-05-20 12:38:04 > ng serve --host 0.0.0.0
2024-05-20 12:38:04
2024-05-20 12:38:04 Please update your Node.js version or visit
https://nodejs.org/ for additional instructions.
2024-05-20 12:38:04
Dockerfile:
FROM node:16-alpine
RUN apk update && apk add python3 make g++
The problem was the Node version indeed. Using Node v 18 in favour of v 16 solved the problem.