我正在尝试在azure上部署docker映像。我能够成功创建docker映像,也可以成功部署。但是我在为容器创建部署所指定的URL上看不到任何内容。我的应用程序是也使用破折号的python flask应用程序。
我关注了this azure tutorial from documentation。该示例应用程序有效。但是我的应用程序没有。我不知道该如何调试或我哪里出错了。
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命令
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
但是当我去http://spo-third-trial.eastus.azurecontainer.io
时,我得到了。
无法访问此网站spo-trial.eastus.azurecontainer.io花了很长时间才响应。 在Google中搜索spo三次试用Eastus azure容器io ERR_CONNECTION_TIMED_OUT
使用此命令sudo az container logs --resource-group myResourceGroup --name spo-third-trial
访问日志时,我得到了
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
我的卷曲输出
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
我不知道我在创建docker或使用Azure或两者时是否做错了什么。非常感谢我能提供的帮助。
注意:我正在使用虚拟PC-AWS客户端,以访问客户端内部的azure。
答案 0 :(得分:1)
如前所述,您的问题有几点:
--ports 80 8050
的意思是that you expose both ports,而不是您将一个映射到另一个。127.0.0.1
上侦听,而不是在0.0.0.0
上侦听。因此,它不接受来自外部的请求。