我有以下 Dockerfile
FROM jupyter/scipy-notebook
#RUN apt-get update && apt-get install -y curl
RUN pip install mlflow
RUN pip install sklearn
RUN apt-get update && apt-get install -y curl
當我做
docker build -t mycontainer .
我明白了
Step 4/4 : RUN apt-get update && apt-get install -y curl
---> Running in 5defd9816a22
Reading package lists...
E: List directory /var/lib/apt/lists/partial is missing. - Acquire (13: Permission denied)
The command '/bin/bash -o pipefail -c apt-get update && apt-get install -y curl' returned a non-zero code: 100
我懷疑這與不以 root 身份運行有關嗎?那么如何從 Dockerfile 在我的容器中安裝 curl?
編輯:我應用了我得到的答案。不幸的是,它沒有用
Step 4/7 : USER root
---> Running in aa6a1b7a023f
Removing intermediate container aa6a1b7a023f
---> 59e87b9598b2
Step 5/7 : RUN apt-get update && apt-get install -y curl
---> Running in 4440ce61ebc6
Err:1 http://security.ubuntu.com/ubuntu focal-security InRelease
Temporary failure resolving 'security.ubuntu.com'
Err:2 http://archive.ubuntu.com/ubuntu focal InRelease
Temporary failure resolving 'archive.ubuntu.com'
Err:3 http://archive.ubuntu.com/ubuntu focal-updates InRelease
Temporary failure resolving 'archive.ubuntu.com'
Err:4 http://archive.ubuntu.com/ubuntu focal-backports InRelease
Temporary failure resolving 'archive.ubuntu.com'
Reading package lists...
W: Failed to fetch http://archive.ubuntu.com/ubuntu/dists/focal/InRelease Temporary failure resolving 'archive.ubuntu.com'
W: Failed to fetch http://archive.ubuntu.com/ubuntu/dists/focal-updates/InRelease Temporary failure resolving 'archive.ubuntu.com'
W: Failed to fetch http://archive.ubuntu.com/ubuntu/dists/focal-backports/InRelease Temporary failure resolving 'archive.ubuntu.com'
W: Failed to fetch http://security.ubuntu.com/ubuntu/dists/focal-security/InRelease Temporary failure resolving 'security.ubuntu.com'
W: Some index files failed to download. They have been ignored, or old ones used instead.
Reading package lists...
Building dependency tree...
Reading state information...
E: Unable to locate package curl
The command '/bin/bash -o pipefail -c apt-get update && apt-get install -y curl' returned a non-zero code: 100
EDIT2:我在不同的網路設定中嘗試過它并且它有效。
uj5u.com熱心網友回復:
嘗試apt
創建/var/lib/apt/lists/partial
. 這是因為您的行程沒有運行為root
; 該jupyter/scipy-notebook
影像被配置為以非root
用戶身份運行(它以用戶身份運行jovyan
)。
您可以使用指令更改運行命令的用戶Dockerfile
,USER
如下所示:
FROM jupyter/scipy-notebook
RUN pip install mlflow
RUN pip install sklearn
USER root
RUN apt-get update && apt-get install -y curl
USER jovyan
jovyan
請注意,我已確保在運行apt-get
命令后將用戶重置回。
uj5u.com熱心網友回復:
嘗試root
像在官方jupyter/scipy-notebook
Dockerfile中一樣安裝它并將其設定回$NB_UID
:(請參閱官方基礎 docker 映像中的用戶宣告)
USER root
# Install packages you need:
RUN apt-get update && apt-get install -y curl
# Switch back to jovyan to avoid accidental container runs as root
USER $NB_UID
以下是使用的基礎 docker 鏡像的層次結構jupyter/scipy-notebook
:
jupyter/base-notebook -> jupyter/minimal-notebook -> jupyter/scipy-notebook
轉載請註明出處,本文鏈接:https://www.uj5u.com/caozuo/507051.html