我已经在运行Windows 10的本地计算机上构建了一个docker映像
运行docker-compose build
,docker-compose up -d
和docker-compse logs -f
确实会产生预期的结果(无错误)
通过运行winpty docker container run -i -t -p 8000:8000 --rm altf1be.plotly.docker-compose:2019-12-17
我将docker映像上传到私有Azure容器注册表中
我基于docker镜像Azure Portal > Container registry > Repositories > altf1be.plotly.docker-compose > v2019-12-17 > context-menu > deploy to web app
The service is unavailable
我的方法有什么问题?
预先感谢您花时间在此问题上
version: '3.7'
services:
twikey-plot_ly_service:
# container_name: altf1be.plotly.docker-container-name
build: .
image: altf1be.plotly.docker-compose:2019-12-17
command: gunicorn --config=app/conf/gunicorn.conf.docker.staging.py app.webapp:server
ports:
- 8000:8000
env_file: .env.staging
apiUrl=https://api.beta.alt-f1.be
authorizationUrl=/api/auth/authorization/code
serverUrl=https://dunningcashflow-api.alt-f1.be
transactionFeedUrl=/creditor/tx
api_token=ANICETOKEN
# read the Dockerfile reference documentation
# https://docs.docker.com/engine/reference/builder
# build the docker
# docker build -t altf1be.plotly.docker-compose:2019-12-17.
# https://docs.microsoft.com/en-us/azure/app-service/containers/tutorial-custom-docker-image#use-a-docker-image-from-any-private-registry-optional
# Use the docker images used by Microsoft on Azure
FROM mcr.microsoft.com/oryx/python:3.7-20190712.5
LABEL Name=altf1.be/plotly Version=1.19.0
LABEL maintainer="abo+plotly_docker_staging@alt-f1.be"
RUN mkdir /code
WORKDIR /code
ADD requirements.txt /code/
# copy the code from the local drive to the docker
ADD . /code/
# non interactive front-end
ARG DEBIAN_FRONTEND=noninteractive
# update the software repository
ENV SSH_PASSWD 'root:!astrongpassword!'
RUN apt-get update && apt-get install -y \
apt-utils \
# enable SSH
&& apt-get install -y --no-install-recommends openssh-server \
&& echo "$SSH_PASSWD" | chpasswd
RUN chmod u+x /code/init_container.sh
# update the python packages and libraries
RUN pip3 install --upgrade pip
RUN pip3 install --upgrade setuptools
RUN pip3 install --upgrade wheel
RUN pip3 install -r requirements.txt
# copy sshd_config file. See https://man.openbsd.org/sshd_config
COPY sshd_config /etc/ssh/
EXPOSE 8000 2222
ENV PORT 8000
ENV SSH_PORT 2222
# install dependencies
ENV ACCEPT_EULA=Y
ENV APPENGINE_INSTANCE_CLASS=F2
ENV apiUrl=https://api.beta.alt-f1.be
ENV serverUrl=https://dunningcashflow-api.alt-f1.be
ENV DOCKER_REGISTRY altf1be.azurecr.io
ENTRYPOINT ["/code/init_container.sh"]
gunicorn --config=app/conf/gunicorn.conf.docker.staging.py app.webapp:server
# -*- coding: utf-8 -*-
workers = 1
# print("workers: {}".format(workers))
bind = '0.0.0.0'
timeout = 600
log_level = "debug"
reload = True
print(
f"workers={workers} bind={bind} timeout={timeout} --log-level={log_level} --reload={reload}"
)
错误-站点altf1be-plotly-docker的容器altf1be-plotly-docker_0_ee297002已退出,站点启动失败
错误-容器altf1be-plotly-docker_0_ee297002没有响应端口8000上的HTTP ping,站点启动失败。请参阅容器日志以进行调试。
答案 0 :(得分:1)
我看到的是您使用了错误的环境变量,它应该是WEBSITES_PORT
,但您错过了WEBSITE
后面的s。您可以添加它,然后尝试再次部署该映像。
而且我认为Azure Web App无法像使用选项env_file
在docker-compose文件中那样为您设置环境变量。因此,我建议您通过命令docker build
创建映像,并通过-e
设置环境变量在本地对其进行测试。当图像运行良好时,您可以将其推送到ACr并通过Web应用程序中的环境变量从ACR进行部署。
或者,您仍然可以使用docker-compose文件在Web App中部署映像,而不是在映像时使用env_file
和build
的{{1}}和environment
在ACR中。