简体   繁体   中英

Angular2 deployment to Azure Container Instance using Docker-Unable to access the app

Created a simple angular2 app through following steps:

npm install -g angular-cli
ng new demo2 (If packages are not getting installed go to demo2 folder and 
execute npm install)
ng server
Navigate to localhost:4200(app works!!!!)

Have not any changes to the angular code!!!!

Added a Dockerfile and .dockerignore to the root of the application This is my Dockerfile file content:

  FROM nginx
  COPY dist /usr/share/nginx/html
  EXPOSE 82

Created the image and container and was able to run the app locally through following steps:

ng build --prod
docker build -t angulardockertest:v1 .
docker images
docker run -p 82:80 -it angulardockertest:v1
Navigate to localhost:82   (app works!!!!)

As a next step i pushed image to Azure container registry and created a container instance(port# given as 82) out of it through the following steps:

docker login pocdockerregistry.azurecr.io
docker tag angulardockertest:v1 pocdockerregistry.azurecr.io/angulardockertest:v1
docker push pocdockerregistry.azurecr.io/angulardockertest:v1

Now when i try to access it (ipaddress:port#) i get the following error: This site can't be reached.refused to connect.

Can someone help me on what is that i am missing/doing it wrong?

First check if app is running fine or not on azure server by using curl localhost:port .
if above is working, to access from your local system please check if you have assigned a public IP to the azure server system and open the firewall port with http protocol.

Did you actually ran the 'az container create' command to create the container in Azure?

I am facing a similar issue with node.js server app running inside docker. If i deploy it to Azure App Service, it is accessible but if i deploy it to Azure Container Instance, i am not able to access it through my organization's network. Even after disabling the firewall, i am unable to access it. Curl is also unable to access it.

It only works outside my organization's network so i need to talk to the IT department. Can you share if you are trying to access it from an organization's network or a public network?

I spoke to Microsoft support and the sample ACI app they are running is not accessible from my organization network either so it's not an app issue.

Also, try this as the starting command in Dockerfile:

ng serve --host 0.0.0.0

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM