我测试了官方的教程,是可以的。但是自己的老是部署失败。
以下是docker的日志:
2021-07-05 15:24:57 create_version_describe_cluster : succ,
2021-07-05 15:24:57 create_version_check_vpc : succ,
2021-07-05 15:25:00 create_build_image : succ,
2021-07-05 15:25:00 check_build_image : succ, ,
[2021-07-05 15:25:41] + docker push ccr.ccs.tencentyun.com/tcb-******-ricf/voice1-6gjzp1us58e7ddf3_backtest:backtest-007-1625469896
[2021-07-05 15:25:41] The push refers to repository [ccr.ccs.tencentyun.com/tcb-******-ricf/voice1-6gjzp1us58e7ddf3_backtest]
[2021-07-05 15:25:41] 96fc7c114884: Preparing
[2021-07-05 15:25:41] 2bac564fad74: Preparing
[2021-07-05 15:25:41] 23aa0ef6de9e: Preparing
[2021-07-05 15:25:41] abbd1e0c6d6b: Preparing
[2021-07-05 15:25:41] 8dd62b771c62: Preparing
[2021-07-05 15:25:41] 2138286d3aea: Preparing
[2021-07-05 15:25:41] 537313a13d90: Preparing
[2021-07-05 15:25:41] 764055ebc9a7: Preparing
[2021-07-05 15:25:41] 764055ebc9a7: Layer already exists
[2021-07-05 15:25:41] 537313a13d90: Layer already exists
[2021-07-05 15:25:41] 8dd62b771c62: Layer already exists
[2021-07-05 15:25:41] 2138286d3aea: Layer already exists
[2021-07-05 15:25:41] abbd1e0c6d6b: Layer already exists
[2021-07-05 15:25:42] 23aa0ef6de9e: Pushed
[2021-07-05 15:25:46] 96fc7c114884: Pushed
[2021-07-05 15:26:08] 2bac564fad74: Pushed
[2021-07-05 15:26:10] backtest-007-1625469896: digest: sha256:8e7b24fa58bc1fbb2ec0ec79e0d9dc7dd19e3caad711d9d5894be5a3d2bc366c size: 2000
-----------服务backtest部署backtest-007-----------
2021-07-05 15:26:13 create_eks_virtual_service : succ,
2021-07-05 15:26:13 check_eks_virtual_service : succ, Back-off restarting failed container, AssumePod failed: pod 46eea07a-dd62-11eb-8e42-42a067703286 is in the cache, so can't be assumed;
Successfully assigned default/backtest-007-7749f957b8-t6956 to eklet-subnet-e8dbv5qv;
Starting pod sandbox eks-infbu3lh; Sync endpoints;
Pulling image "ccr.ccs.tencentyun.com/tcb-100007991978-ricf/voice1-6gjzp1us58e7ddf3_backtest:backtest-007-1625469896";
Successfully pulled image "ccr.ccs.tencentyun.com/tcb-100007991978-ricf/voice1-6gjzp1us58e7ddf3_backtest:backtest-007-1625469896" in 22.174537779s;
Created container backtest-007; Started container backtest-007;
Container image "ccr.ccs.tencentyun.com/tcb-100007991978-ricf/voice1-6gjzp1us58e7ddf3_backtest:backtest-007-1625469896" already present on machine;
Back-off restarting failed container
这是我的Dockerfile:
# 使用官方 Python 轻量级镜像
# https://hub.docker.com/_/python
FROM python:3.8-slim
# 将本地代码拷贝到容器内
ENV APP_HOME /app
WORKDIR $APP_HOME
COPY . ./
# 安装依赖
RUN pip install Flask==1.1.2 gunicorn==20.1.0 xlsxwriter==1.2.8 sqlalchemy==1.3.17
# 启动 Web 服务
# 这里我们使用了 gunicorn 作为 Server,1 个 worker 和 8 个线程
# 如果您的容器实例拥有多个 CPU 核心,我们推荐您把线程数设置为与 CPU 核心数一致
CMD exec gunicorn --bind :80 --workers 1 --threads 8 --timeout 0 main:app
事实上,和官网的教程中给的Dockerfile一模一样,只是由于有excel和数据库需求,加了两个库。
以下是main.py的部分代码:
if __name__=='__main__':
app.run(
debug=True,
host='0.0.0.0',
port=80
)
下面是我文件夹目录:
PS F:\WeChatProjects\FiveNotesSqlalchemy> tree /f
文件夹 PATH 列表
卷序列号为 4FA9-A3BE
F:.
.dockerignore
.gitignore
0021.mp3
0031.mp3
0041.mp3
1001.mp3
1002.mp3
2001.mp3
2002.mp3
3001.mp3
3002.mp3
4001.mp3
5001.mp3
5002.mp3
6000.mp3
Dockerfile
insert.py
main.py
problemlog.txt
query.py
tables.py
tools.py
update.py
没有子文件夹
谢谢!
已解决。有一点想吐槽,页面上两个输出日志的地方。但是日志输出不同,一个是docker build的日志,一个是docker内应用的日志。需要写的更清楚一点!