Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

844
Visualizações
Running Angular app as docker image using Node js

Trying to build angular application in docker and run as container in my local using Node js.

I have used build image using below Dockerfile, but i am not sure what i am missing while running. Can someone point me out?

Dockerfile:

FROM node:10.15.3
ENV HOME=/home
WORKDIR $HOME
RUN npm config set strict-ssl false \
    && npm config set proxy http://proxy.xxxxxx.com:8080
COPY package.json .
RUN npm install

Image created with below command successfully

docker build -t example .

I am trying to run the image using below command, but it is not helping

docker run -p 4201:4200 example
over 4 years ago · Santiago Trujillo
3 Respostas
Responde à pergunta

0

your Dockerfile does not run/serve your application, in order to do that you have to:

  • install angular/cli
  • copy the app
  • run/serve the app
FROM node:10.15.3

RUN npm config set strict-ssl false \
    && npm config set proxy http://proxy.xxxxxx.com:8080

# get the app
WORKDIR /src
COPY . .

# install packages
RUN npm ci
RUN npm install -g @angular/cli

# start app
CMD ng serve --host 0.0.0.0

hope this helps.

over 4 years ago · Santiago Trujillo Relatório

0

Container need a foreground process running, then it will not exit. If not, the container will directly exit.

For your case, you need to COPY your nodejs project to container when docker build, and also start the project in CMD like CMD [ "npm", "start" ]. As the web server not exit, then your container will not exit.

A good article here for your reference on how to dockerizing a Node.js web app.

over 4 years ago · Santiago Trujillo Relatório

0

Just update your Dockerfile to achieve your goal for more options see here:

# base image
FROM node:12.2.0

RUN npm config set strict-ssl false \
    && npm config set proxy http://proxy.xxxxxx.com:8080

# install chrome for protractor tests
RUN wget -q -O - https://dl-ssl.google.com/linux/linux_signing_key.pub | apt-key add -
RUN sh -c 'echo "deb [arch=amd64] http://dl.google.com/linux/chrome/deb/ stable main" >> /etc/apt/sources.list.d/google.list'
RUN apt-get update && apt-get install -yq google-chrome-stable

# set working directory
WORKDIR /app

# add `/app/node_modules/.bin` to $PATH
ENV PATH /app/node_modules/.bin:$PATH

# install and cache app dependencies
COPY package.json /app/package.json
RUN npm install
RUN npm install -g @angular/cli@7.3.9

# add app
COPY . /app

# start app
CMD ng serve --host 0.0.0.0 
over 4 years ago · Santiago Trujillo Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda