OCI runtime create failed: container_linux.go:345: starting container process caused “exec: \“pip\“
解决:OCI runtime create failed: container_linux.go:345: starting container process caused "exec: \"pip\"
·
OCI runtime create failed: container_linux.go:345: starting container process caused "exec: \"pip\": executable file not found in $PATH": unknown
Docker Dockerfile
Dockerfile 是一个用来构建镜像的文本文件,文本内容包含了一条条构建镜像所需的指令和说明。
本文在制作 BERT 文本分类模型镜像时,碰到的 docke build 的 pip 错误:
OCI runtime create failed: container_linux.go:345: starting container process caused “exec: “pip”: executable file not found in $PATH”: unknown
推荐内容
Dockefile 制作镜像
使用 pip 安装依赖包:
pip install -r /home/bert_model/requirements.txt -i https://pypi.tuna.tsinghua.edu.cn/simple
写成 Dockefile 的命令:
RUN ["pip", "install", "-r", "/home/bert_model/requirements.txt", "-i", "https://pypi.tuna.tsinghua.edu.cn/simple"]
Dockefile:
FROM refazul/python3.9.0
ADD bert_model.tar /home
RUN ["pip", "install", "-r", "/home/bert_model/requirements.txt", "-i", "https://pypi.tuna.tsinghua.edu.cn/simple"]
ENTRYPOINT ["bash", "/home/bert_model/run.sh"]
创建镜像
docker build -t bert_model:v1 .
报错信息
详细报错信息如下:
OCI runtime create failed: container_linux.go:345: starting container process caused "exec: \"pip\": executable file not found in $PATH": unknown
解决方法
先创建测试容器
docker run -it -d \
--name test_v2 \
-v /bee/test_model/:/notebooks \
-e TZ='Asia/Shanghai' \
--shm-size 16G \
refazul/python3.9.0:latest
再进入容器
docker exec -it test_v2 bash
查找 pip 路径
执行:
whereis pip
输出:
# whereis pip
pip: /root/.pyenv/shims/pip3.9 /root/.pyenv/shims/pip
可以看出 pip 不在默认的 $PATH 路径下面
修改 pip 路径
修改 Dockefile 中的 pip 命令
RUN ["pip", "install", "-r", "/home/bert_model/requirements.txt", "-i", "https://pypi.tuna.tsinghua.edu.cn/simple"]
为:
RUN ["/root/.pyenv/shims/pip", "install", "-r", "/home/bert_model/requirements.txt", "-i", "https://pypi.tuna.tsinghua.edu.cn/simple"]
Dockefile:
FROM refazul/python3.9.0
ADD bert_model.tar /home
RUN ["/root/.pyenv/shims/pip", "install", "-r", "/home/bert_model/requirements.txt", "-i", "https://pypi.tuna.tsinghua.edu.cn/simple"]
ENTRYPOINT ["bash", "/home/bert_model/run.sh"]
再执行:
docker build -t bert_model:v1 .
执行成功,输出:
Removing intermediate container 214e6260dbca
---> 8052d3dacd3f
Step 4/4 : ENTRYPOINT ["bash", "/home/bert_model/run.sh"]
---> Running in b59877caf0fc
Removing intermediate container b59877caf0fc
---> fc79cd19acb5
Successfully built fc79cd19acb5
Successfully tagged bert_model:v1
参考
点击阅读全文
更多推荐
社区排行榜
Go语言基础
活动日历
查看更多
直播时间 2022-05-31 13:51:24

CSDN云原生系列在线峰会:K8s大规模应用和深度实践峰会
直播时间 2023-09-14 18:47:34

腾讯云优质活动用户线上技术漫谈
直播时间 2023-09-13 13:47:50

CloudOps云上自动化运维,助力云上业务高效、稳定运行
直播时间 2023-09-06 09:21:46

2023 Google 开发者大会 主旨演讲
直播时间 2023-08-31 18:49:52

TDSQL-C Serverless助力企业降本增效
目录
所有评论(0)