Dockerize Your Angular Application

OS: mac

IDE:VSCODE

1.create your angular
ng new angular1
ng serve

angular project running.

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

now your angular already running on docker.

ref:
https://ubuntu1804.blogspot.com/2021/01/web-angular-docker.html

--

--

Jameskrauser Lee

For the last few years. i was involved mostly in the development of Automatic Fare collection system for the Chennai Metro. Familiar with C++ and iOS.