所以我构建了一个 docker 映像文件,现在当我尝试运行它时,它给了我错误:
运行镜像失败。错误:(HTTP 代码 400)意外 - 无法为容器创建任务:无法创建 shim 任务:OCI 运行时创建失败:runc 创建失败:无法启动容器进程:exec:“jupyter”:在 $PATH 中找不到可执行文件: 未知
Dockerfile:
FROM python:3.10-slim-bullseye
WORKDIR /project_dir
RUN apt-get update \
&& apt-get install -y build-essential unzip \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*
RUN pip install kaggle
COPY requirements.txt /project_dir/
RUN pip install --no-cache-dir -r requirements.txt
COPY kaggle.json /root/.kaggle/kaggle.json
RUN chmod 600 /root/.kaggle/kaggle.json
RUN kaggle datasets download -d odins0n/ucf-crime-dataset -p /app/kaggle_dataset/ \
&& unzip /app/kaggle_dataset/ucf-crime-dataset.zip -d /app/kaggle_dataset/ \
&& rm /app/kaggle_dataset/ucf-crime-dataset.zip
COPY . /project_dir/
CMD ["jupyter", "notebook", "--ip='*'", "--port=8888", "--no-browser", "--allow-root"]
所以现在我必须修改我的 dockerfile 并在其中包含
pip install jupyter
。
现在我想知道是否有任何方法可以加快构建过程或直接跳过它并直接在容器中安装 Jupyter。
容器是一个运行的镜像。您可以向容器添加任何内容,但这些更改不是持久的。在这种情况下,您想要保留您的更正,因此您必须重建图像。这就是 Docker 的工作原理。一旦获得正确的映像,您就可以在任何环境中使用它创建容器。