I have the following Dockerfile where I want to build a Docker container from the image at https://hub.docker.com/r/julianassmann/opencv-cuda/:
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
I have the following error:
ERROR: failed to solve: process "/bin/sh -c apt-get update" did not complete successfully: exit code: 100
I don't understand the problem as I have installed sudo with the previous commands:
RUN apt-get update
RUN apt-get -y install sudo
I downloaded your
Dockerfileand first error which you also stated is connected withapt-get update, it states that it can not find signatures (Public part of GPG keys) fornvidiapackages.I found the solution for this part on https://askubuntu.com/questions/1444943/nvidia-gpg-error-the-following-signatures-couldnt-be-verified-because-the-publi
Fix is to add public keys before your apt-get update
Like so.
When this step was done I tried rebuilding the image again, and then you have an error with installing
pipon Ubuntu 18.On this line:
And the fix for this is found here:
"E: Unable to locate package python-pip" on Ubuntu 18.04
Which says you need to install
python3-pipinstead of justpipfor thepython3dependency.Which makes it:
The whole
Dockerfilewith these adjustments is:NOTE:
You still have one more error to solve:
But I commented out this line from the
Dockerfile, and it was built, Using the commanddocker image build -t cuda-test:0.0.1 .