Error al crear el tiempo de ejecución de OCI: contenedor_linux.go:345: el inicio del proceso del contenedor provocó "exec: \"pip\": archivo ejecutable no encontrado en $PATH": desconocido
Archivo Docker
Dockerfile es un archivo de texto que se utiliza para construir un espejo y el contenido del texto contiene instrucciones e instrucciones para construir un espejo.
En este artículo, al crear una imagen del modelo de clasificación de texto BERT, se encontró el error de pip de compilación de Docke: Error al
crear el tiempo de ejecución de OCI: contenedor_linux.go:345: el proceso de inicio del contenedor provocó “exec: “pip”: el archivo ejecutable no se encuentra en $PATH” : desconocido
Dockefile para hacer una imagen reflejada
Utilice pip para instalar dependencias:
pip install -r /home/bert_model/requirements.txt -i https://pypi.tuna.tsinghua.edu.cn/simple
Comando escrito como Dockefile:
RUN ["pip", "install", "-r", "/home/bert_model/requirements.txt", "-i", "https://pypi.tuna.tsinghua.edu.cn/simple"]
Archivo Docke:
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"]
crear espejo
docker build -t bert_model:v1 .
mensaje de error
La información detallada del error es la siguiente:
OCI runtime create failed: container_linux.go:345: starting container process caused "exec: \"pip\": executable file not found in $PATH": unknown
Solución
Primero cree un contenedor de prueba
docker run -it -d \
--name test_v2 \
-v /bee/test_model/:/notebooks \
-e TZ='Asia/Shanghai' \
--shm-size 16G \
refazul/python3.9.0:latest
volver a entrar en el contenedor
docker exec -it test_v2 bash
Encuentra la ruta del pip
implementar:
whereis pip
producción:
# whereis pip
pip: /root/.pyenv/shims/pip3.9 /root/.pyenv/shims/pip
Se puede ver que pip no está en la ruta $PATH predeterminada.
Modificar la ruta del pip
Modificar el comando pip en el Dockefile
RUN ["pip", "install", "-r", "/home/bert_model/requirements.txt", "-i", "https://pypi.tuna.tsinghua.edu.cn/simple"]
para:
RUN ["/root/.pyenv/shims/pip", "install", "-r", "/home/bert_model/requirements.txt", "-i", "https://pypi.tuna.tsinghua.edu.cn/simple"]
Archivo Docke:
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"]
Ejecutar nuevamente:
docker build -t bert_model:v1 .
La ejecución es exitosa, salida:
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