scientific_explorer
scientific_explorer

Reputation: 915

Azure Container Instance not showing anything via url after deployment

I am trying to deploy a docker image on azure. I am able to create the docker image successfully, also deploy successfully. But I am not able to see anything on my URL I specified to create the deployment for container. My app is a python flask app which also uses dash.

I followed this azure tutorial from documentation. The example app works. But my app does not. I don't know how to debug this or where I am going wrong.

Dockerfile

FROM ubuntu:18.04

COPY . /app

WORKDIR /app

RUN apt update && \
    apt install -y make curl gcc g++ gfortran git patch wget unixodbc-dev vim-tiny build-essential \
    libssl-dev zlib1g-dev libncurses5-dev libncursesw5-dev libreadline-dev libsqlite3-dev \
    libgdbm-dev libdb5.3-dev libbz2-dev libexpat1-dev liblzma-dev libffi-dev && \
    apt install -y python3 python3-dev python3-pip python3-venv && \
    curl https://packages.microsoft.com/keys/microsoft.asc | apt-key add - && \
    curl https://packages.microsoft.com/config/ubuntu/18.04/prod.list > /etc/apt/sources.list.d/mssql-release.list && \
    apt update && \
    ACCEPT_EULA=Y apt-get -y install msodbcsql17 && \
    python3 -m venv spo_venv && \
    . spo_venv/bin/activate && \
    pip3 install --upgrade pip && \
    pip3 install wheel && \
    pip3 install -r requirements.txt && \
    cd / && \
    wget http://download.redis.io/releases/redis-5.0.5.tar.gz && \
    tar xzf redis-5.0.5.tar.gz && \
    cd redis-5.0.5 && \
    make && \
#    make test && \
    cd / && \
    rm redis-5.0.5.tar.gz && \
    cd / && \
    wget https://www.coin-or.org/download/source/Ipopt/Ipopt-3.12.13.tgz && \
    tar xvzf Ipopt-3.12.13.tgz && \
    cd Ipopt-3.12.13/ThirdParty/Blas/ && \
    ./get.Blas && \
    cd ../Lapack && \
    ./get.Lapack && \
    cd ../Mumps && \
    ./get.Mumps && \
    cd ../Metis && \
    ./get.Metis && \
    cd ../../ && \
    mkdir build && \
    cd build && \
    ../configure && \
    make -j 4 && \
    make install && \
    cd / && \
    rm Ipopt-3.12.13.tgz && \
    echo "export PATH=\"$PATH:/redis-5.0.5/src/\"" >> ~/.bashrc && \
   . ~/.bashrc

CMD ["./commands.sh"]

commands.sh

#!/bin/sh
. spo_venv/bin/activate
nohup redis-server > redislogs.log 2>&1 &
nohup celery worker -A task.celery -l info -P eventlet > celerylogs.log 2>&1 &
python app.py

Azure commands

sudo az acr login --name mynameregistry

sudo az acr show --name mynameregistry--query loginServer --output table

sudo docker tag spo_third_trial:v1 mynameregistry.azurecr.io/spo_third_trial:v1

sudo docker push mynameregistry.azurecr.io/spo_third_trial:v1

sudo az acr repository list --name mynameregistry--output table

sudo az acr repository show-tags --name mynameregistry--repository spo_third_trial --output table

sudo az acr show --name mynameregistry--query loginServer

sudo az container create --resource-group myResourceGroup --name spo-third-trial --image mynameregistry.azurecr.io/spo_third_trial:v1 --cpu 1 --memory 1 --registry-login-server mynameregistry.azurecr.io --registry-username mynameregistry --registry-password randomPassword --dns-name-label spo-third-trial --ports 80 8050

But when I go to http://spo-third-trial.eastus.azurecontainer.io I get this.

This site can’t be reached spo-third-trial.eastus.azurecontainer.io took too long to respond. Search Google for spo third trial eastus azure container io ERR_CONNECTION_TIMED_OUT

enter image description here

When I access logs with this command sudo az container logs --resource-group myResourceGroup --name spo-third-trial I get this

Running on http://127.0.0.1:8050/
Debugger PIN: 950-132-306
 * Serving Flask app "server" (lazy loading)
 * Environment: production
   WARNING: This is a development server. Do not use it in a production deployment.
   Use a production WSGI server instead.
 * Debug mode: on
Running on http://127.0.0.1:8050/
Debugger PIN: 871-957-278

My curl output

 curl -v http://spo-third-trial.eastus.azurecontainer.io

* Rebuilt URL to: http://spo-third-trial.eastus.azurecontainer.io/
*   Trying <ip-address>...
* TCP_NODELAY set
* connect to <ip-address> port 80 failed: Connection timed out
* Failed to connect to spo-third-trial.eastus.azurecontainer.io port 80: Connection timed out
* Closing connection 0
curl: (7) Failed to connect to spo-third-trial.eastus.azurecontainer.io port 80: Connection timed out

I don't understand whether I am doing something wrong with creating docker, or with azure, or both. Would appreciate any help I can get.

NOTE: I am working on a virtual PC - AWS client, to access azure inside the client.

Upvotes: 0

Views: 2290

Answers (1)

silent
silent

Reputation: 16138

As discussed, a couple of points to your question:

  • I think you meant to map the internal port 8050 to the external port 80. But this is not possible currently (Aug-2019) in Azure Container Instances. There is an open item on Uservoice for this. --ports 80 8050 means that you expose both ports, not that you map one to the other.
  • The actual problem, as we found out, was that the python flask app was listening only on 127.0.0.1, not on 0.0.0.0. So it was not accepting requests from the outside.

Upvotes: 1

Related Questions