Learn how to deploy your Angular Application in a Docker Container
in 5-minutes

Taking an angular application into production can be daunting enough as it is. This is a simple, straight-forward, guide that will have you running your application inside of a docker container in 5-minutes flat.

We’ll use an node.js container to build your application but then move over into an nginx container to serve the final product. It’s a common misconception that running your production built application from a node.js http server is the right way to go. Please do not do this.

By moving into an nginx container we copy only your dist directory and leave everything else behind!


First, place this Dockerfile in your applications root directory:

FROM node:alpine AS builder


COPY package.json .
RUN npm install

COPY . .
RUN npm run build

FROM nginx:alpine

COPY --from=builder /app/dist/fakerai-frontend-ui/* /usr/share/nginx/html/
COPY nginx.conf /etc/nginx/conf.d/default.conf


We need to configure nginx so that it rewrites all urls to index.html for angular processing:

server {

    server_name localhost;
    listen      80;
    root        /usr/share/nginx/html;
    index       index.html index.htm;

    location / {

        try_files $uri $uri/ /index.html;



Docker Commands

Now build your docker image:

$ docker build -t my-angular-app:v1 .

Then run it!

$ docker run -p 80:80 my-angular-app:v1