Dockerize Your Angular Application
Mar 13, 2023
OS: mac
IDE:VSCODE
1.create your angular ng new angular1
ng serve
2. create dockerfile at your project folder
#stage 1
FROM node:latest as node
WORKDIR /app
COPY . .
RUN npm install
RUN npm run build --prod
#stage 2
FROM nginx:alpine
COPY --from=node /app/dist/angular1 /usr/share/nginx/html
3.dockerize your angular project
docker build . -t Angular1
docker images
check your images
4.run my project name angular1 on docker
docker run --name angular1 -d -p 4200:80 angular1
ps:if show Error response from daemon: conflicct, the container name “/xxx” is already in use by container “xxxxxxx”
docker rm angular1
ref:
https://ubuntu1804.blogspot.com/2021/01/web-angular-docker.html