RROR:无法解决:进程“/bin/sh -c apt-get update”

问题描述 投票:0回答:1

我有以下 dockerfile,我想从 https://hub.docker.com/r/julianassmann/opencv-cuda/:

的图像构建 docker 容器
FROM julianassmann/opencv-cuda 
#image name with OpenCV with CUDA

# Edit /etc/default/docker file to add custom DNS server
RUN echo 'DOCKER_OPTS="--dns 172.16.16.10"' >> /etc/default/docker

#working directory where i have placed container 
#on top of container
RUN apt-get update

RUN apt-get -y install sudo

# Install additional packages
RUN sudo apt update \
    #prevent interactive prompts
    && export DEBIAN_FRONTEND=noninteractive \
    && apt install -y lubuntu-desktop net-tools pip python3-tk \
    # Clean up no longer required by any other packages 
    && apt autoremove -y \
    #removes cached package files that were downloaded during the package installation
    && apt clean -y \
    #cached package lists and can be safely removed after installing packages
    && rm -rf /var/lib/apt/lists/* \
    #removes any files with names starting with reboot-required in the /run/ directory to prevent reboot after installing packages
    && rm /run/reboot-required*

# Create a non-root user with sudo priviledges
ARG USERNAME=user
ARG PASSWORD=password
ARG USER_UID=1000
ARG USER_GID=$USER_UID # Group ID (GID) of the user being created
#Creates a group with the specified USER_GID and name USERNAME
RUN groupadd --gid $USER_GID $USERNAME \
    #Creates a user with the specified USER_UID, USER_GID, USERNAME, and encrypted password generated from the PASSWORD. 
    #The -m flag ensures that a home directory is created for the user.
    #/bin/bash refers to the Bash shell executable binary file. Unix-like operating system,you specify the user's default shell
    && useradd -s /bin/bash --uid $USER_UID --gid $USER_GID -m $USERNAME -p $(openssl passwd $PASSWORD) \
    # [Optional] Add sudo support for the non-root user
    && apt update \
    && apt install -y sudo \
    #username allow execute commands as root without entering a password
    && echo $USERNAME ALL=\(root\) NOPASSWD:ALL > /etc/sudoers.d/$USERNAME\
    #Sets appropriate permissions
    && chmod 0440 /etc/sudoers.d/$USERNAME \
    # Clean up
    && apt autoremove -y \
    && apt clean -y \
    && rm -rf /var/lib/apt/lists/* \
    # provide auto-completion functionality when typing commands in the Bash shell
    && echo "source /usr/share/bash-completion/completions/git" >> /home/$USERNAME/.bashrc \
    # Configure remote desktop
    RUN adduser xrdp ssl-cert
RUN sed -i '3 a echo " \
    export GNOME_SHELL_SESSION_MODE=Lubuntu\\n\
    export XDG_SESSION_TYPE=x11\\n\
    export XDG_CURRENT_DESKTOP=LXQt\\n\
    export XDG_CONFIG_DIRS=/etc/xdg/xdg-Lubuntu:/etc/xdg\\n\
    " > ~/.xsessionrc' /etc/xrdp/startwm.sh
#default port used by Remote Desktop Protocol (RDP)
EXPOSE 3389

# Install Python dependencies
COPY requirements.txt .
RUN pip install --disable-pip-version-check --no-cache-dir -U -r requirements.txt \
    && rm requirements.txt

# Start xrdp and a bash terminal
CMD service xrdp start ; bash

我有以下错误:

错误:无法解决:进程“/bin/sh -c apt-get update”未完成 suc 成功:退出代码:100

我不明白这个问题,因为我已经使用前面的命令安装了 sudo:

RUN apt-get update

RUN apt-get -y install sudo
docker ubuntu dockerfile sudo apt-get
1个回答
0
投票

我下载了你的 Dockerfile,你也提到了第一个错误与 apt-get update 有关,它指出它找不到 nvidia 软件包的签名(GPG 密钥的公共部分)。

5.095 W: GPG error: https://developer.download.nvidia.com/compute/cuda/repos/ubuntu1804/x86_64  InRelease: The following signatures couldn't be verified because the public key is not available: NO_PUBKEY A4B469963BF863CC
5.095 E: The repository 'https://developer.download.nvidia.com/compute/cuda/repos/ubuntu1804/x86_64  InRelease' is not signed.

我在https://askubuntu.com/questions/1444943/nvidia-gpg-error-the-following-signatures-couldnt-be-verified-because-the-publi

找到了这部分的解决方案

修复方法是在 apt-get 更新之前添加公钥


RUN apt-key adv --fetch-keys https://developer.download.nvidia.com/compute/cuda/repos/ubuntu1804/x86_64/3bf863cc.pub
RUN apt-key adv --fetch-keys https://developer.download.nvidia.com/compute/machine-learning/repos/ubuntu1804/x86_64/7fa2af80.pub

RUN apt-get update

RUN apt-get -y install sudo

就像这样。

完成此步骤后,我再次尝试重建映像,然后在 ubuntu 18 上安装 pip 时出错。

在这一行:&& apt install -y lubuntu-desktop net-tools python3-pip python3-tk \

2.876 Reading state information...
2.937 E: Unable to locate package pip

并找到了解决此问题的方法:

Ubuntu 18.04 上的“E:无法找到 python-pip 包”

这表示你需要安装 python3-pip 而不是仅仅安装 pip 来获得 python3 依赖。

这使得它:

&& apt install -y lubuntu-desktop net-tools python3-pip python3-tk \

经过这些调整的整个 dockerfile 是:

FROM julianassmann/opencv-cuda 
#image name with OpenCV with CUDA

# Edit /etc/default/docker file to add custom DNS server
RUN echo 'DOCKER_OPTS="--dns 172.16.16.10"' >> /etc/default/docker

#working directory where i have placed container 
#on top of container

RUN apt-key adv --fetch-keys https://developer.download.nvidia.com/compute/cuda/repos/ubuntu1804/x86_64/3bf863cc.pub
RUN apt-key adv --fetch-keys https://developer.download.nvidia.com/compute/machine-learning/repos/ubuntu1804/x86_64/7fa2af80.pub

RUN apt-get update

RUN apt-get -y install sudo

# Install additional packages
RUN apt update \
    #prevent interactive prompts
    && export DEBIAN_FRONTEND=noninteractive \
    && apt install -y lubuntu-desktop net-tools python3-pip python3-tk \
    # Clean up no longer required by any other packages 
    && apt autoremove -y \
    #removes cached package files that were downloaded during the package installation
    && apt clean -y \
    #cached package lists and can be safely removed after installing packages
    && rm -rf /var/lib/apt/lists/* \
    #removes any files with names starting with reboot-required in the /run/ directory to prevent reboot after installing packages
    && rm /run/reboot-required*

# Create a non-root user with sudo priviledges
ARG USERNAME=user
ARG PASSWORD=password
ARG USER_UID=1000
ARG USER_GID=$USER_UID # Group ID (GID) of the user being created
#Creates a group with the specified USER_GID and name USERNAME
RUN groupadd --gid $USER_GID $USERNAME \
    #Creates a user with the specified USER_UID, USER_GID, USERNAME, and encrypted password generated from the PASSWORD. 
    #The -m flag ensures that a home directory is created for the user.
    #/bin/bash refers to the Bash shell executable binary file. Unix-like operating system,you specify the user's default shell
    && useradd -s /bin/bash --uid $USER_UID --gid $USER_GID -m $USERNAME -p $(openssl passwd $PASSWORD) \
    # [Optional] Add sudo support for the non-root user
    && apt update \
    && apt install -y sudo \
    #username allow execute commands as root without entering a password
    && echo $USERNAME ALL=\(root\) NOPASSWD:ALL > /etc/sudoers.d/$USERNAME\
    #Sets appropriate permissions
    && chmod 0440 /etc/sudoers.d/$USERNAME \
    # Clean up
    && apt autoremove -y \
    && apt clean -y \
    && rm -rf /var/lib/apt/lists/* \
    # provide auto-completion functionality when typing commands in the Bash shell
    && echo "source /usr/share/bash-completion/completions/git" >> /home/$USERNAME/.bashrc \
    # Configure remote desktop
    RUN adduser xrdp ssl-cert
RUN sed -i '3 a echo " \
    export GNOME_SHELL_SESSION_MODE=Lubuntu\\n\
    export XDG_SESSION_TYPE=x11\\n\
    export XDG_CURRENT_DESKTOP=LXQt\\n\
    export XDG_CONFIG_DIRS=/etc/xdg/xdg-Lubuntu:/etc/xdg\\n\
    " > ~/.xsessionrc' /etc/xrdp/startwm.sh
#default port used by Remote Desktop Protocol (RDP)
EXPOSE 3389

# Install Python dependencies
COPY requirements.txt .
RUN pip install --disable-pip-version-check --no-cache-dir -U -r requirements.txt \
    && rm requirements.txt

# Start xrdp and a bash terminal
CMD service xrdp start ; bash

注意:

您还有一个错误需要解决:

[ 9/11] 运行 sed -i '3 a echo " 导出 GNOME_SHELL_SESSION_MODE=Lubuntu 导出 XDG_SESSION_TYPE=x11 导出 XDG_CURRENT_DESKTOP=LXQt 导出 XDG_CONFIG_DIRS=/etc/xdg/xdg-Lubuntu:/etc/xdg > ~/.xsessionrc' /etc/xrdp/startwm.sh: 0.419 sed:无法读取/etc/xrdp/startwm.sh:没有这样的文件或目录

但我从 Dockerfile 中注释了这一行,并且它已构建。使用

docker image build -t cuda-test:0.0.1 .
命令。

© www.soinside.com 2019 - 2024. All rights reserved.