Docker build gives "There are no enabled repos" when running yum install - docker

I am trying to dockerfy the installation guide described here:
https://docs.opsmanager.mongodb.com/current/tutorial/install-simple-test-deployment/
I have created this minimal dockerfile:
FROM registry.access.redhat.com/rhel7/rhel:latest
RUN yum install -y mongodb-org mongodb-org-shell
But when I build it I get:
$ docker build . -t my-image
Sending build context to Docker daemon 22.53kB
Step 1/2 : FROM x.y.z:1234/rhel7/rhel:latest
---> 6979ec30598b
Step 2/2 : RUN yum install -y mongodb-org mongodb-org-shell
---> Running in d696383b761d
Loaded plugins: ovl, product-id, search-disabled-repos, subscription-manager
This system is not registered with an entitlement server. You can use subscription-manager to register.
There are no enabled repos.
Run "yum repolist all" to see the repos you have.
To enable Red Hat Subscription Management repositories:
subscription-manager repos --enable <repo>
To enable custom repositories:
yum-config-manager --enable <repo>
From the above guide I need to first add:
echo "[mongodb-org-4.0]
name=MongoDB Repository
baseurl=https://repo.mongodb.org/yum/redhat/7/mongodb-org/4.0/x86_64/
gpgcheck=1
enabled=1
gpgkey=https://www.mongodb.org/static/pgp/server-4.0.asc" | sudo tee /etc/yum.repos.d/mongodb.repo
this to my dockerfile. Any input/examples on how to do that? I guess I basically need to copy the above text block into a /etc/yum.repos.d/mongodb.repo file on the image?
Edit: Based on below answer I can now docker ADD the repo file into the image and the above error is fixed. But I get this instead:
--> Processing Dependency: openssl for package: mongodb-org-tools-4.0.9-1.el7.x86_64
--> Finished Dependency Resolution
Error: Package: mongodb-org-tools-4.0.9-1.el7.x86_64 (mongodb-org-4.0)
Requires: openssl
Error: Package: mongodb-org-server-4.0.9-1.el7.x86_64 (mongodb-org-4.0)
Requires: openssl
Error: Package: mongodb-org-shell-4.0.9-1.el7.x86_64 (mongodb-org-4.0)
Requires: openssl
You could try using --skip-broken to work around the problem
You could try running: rpm -Va --nofiles --nodigest
The command '/bin/sh -c yum install -y mongodb-org mongodb-org-shell' returned a non-zero code: 1
Not sure if that is related to the repo information. I also tried to install openssl in dockerfile with:
RUN yum install openssl
but that gives:
No package openssl available.
Error: Nothing to do
The command '/bin/sh -c yum install openssl' returned a non-zero code: 1

Create a file in the same folder of your Dockerfile with the contents and add them to the image. Example:
cat <<EOF > mongodb.repo
[mongodb-org-4.0]
name=MongoDB Repository
baseurl=https://repo.mongodb.org/yum/redhat/7/mongodb-org/4.0/x86_64/
gpgcheck=1
enabled=1
gpgkey=https://www.mongodb.org/static/pgp/server-4.0.asc
EOF
Then in your Dockerfile:
FROM registry.access.redhat.com/rhel7/rhel:latest
ADD mongodb.repo /etc/yum.repos.d/mongodb.repo
RUN yum update && \
yum install -y mongodb-org mongodb-org-shell

Related

Prevent nvidia-docker from installing nvidia drivers with debian package

I am trying to create an nvidia-docker image with installed TensorRT for my specific application. I can't use any of the provided TensortRT base images, as they are using CUDA version not compatible with the application, but I have a custom TensorRT debian package which is used in my organization. The problem is, when I install it from the Dockerfile, it also installs nvidia drivers. As a result, the container is successfully created, but can't be started - the result is:
svc_moma_usr#PL1LXD-529389:~/gutkowsp/Docker_projects/test_cuda$ nvidia-docker run tensorrt-test
docker: Error response from daemon: OCI runtime create failed: container_linux.go:346: starting container process caused "process_linux.go:449: container init caused \"process_linux.go:432: running prestart hook 1 caused \\\"error running hook: exit status 1, stdout: , stderr: nvidia-container-cli: mount error: file creation failed: /var/lib/docker/overlay2/97f449ff2535b1ad304520dae75c613931888658a66b89235b0d040a872a625c/merged/usr/bin/nvidia-smi: file exists\\\\n\\\"\"": unknown.
ERRO[0001] error waiting for container: context canceled
The dockerfile is:
FROM nvidia/cuda:9.1-devel-ubuntu16.04
ENV DEBIAN_FRONTEND noninteractive
ENV CUDNN_VERSION 7.0.5.15
LABEL com.nvidia.cudnn.version="${CUDNN_VERSION}"
RUN apt update -y && \
apt install software-properties-common -y && \
apt-add-repository --yes --update ppa:ansible/ansible && \
apt install ansible -y
RUN apt update -y && \
apt install -y --no-install-recommends \
libcudnn7=$CUDNN_VERSION-1+cuda9.1 \
libcudnn7-dev=$CUDNN_VERSION-1+cuda9.1
RUN apt update -y && \
apt install tensorrt -y
How this problem of unnecessary drivers is solved? This seems to me like a common issue, as in general nvidia docker images typically have installed nvidia software, which usually comes with drivers. Maybe someone can share the dockerfiles for the TensorRT images for reference?
For anyone who facing the same issue:
If necessary use CUDNN enabled docker image, like 11.7.1-cudnn8-runtime-ubuntu18.04 to avoid the necessity to install it using apt
Run apt update
Run apt install <your package> -y --dry-run | grep nvidia
Add all listed nvidia packages to apt ignore list - add a dash after the package name with an asterisk in place of version number
apt install <your package> libnvidia-compute-*-server- \
libnvidia-compute-*- --dry-run | grep nvidia
Make sure that none of nvidia packages will be installed. If necessary add newly discovered packages to ignore list.
If everything is OK then remove --dry-run flag and install your package
apt install <your package> libnvidia-compute-*-server- libnvidia-compute-*-

How do I install open-ssh client and server in an image of type debian:stretch inside a container?

I need to install ssh in order to run the following command:
git+ssh://git#github.com/some_org/some_repo#egg=some_egg
This failed with the following error:
Collecting athena from git+ssh://git#github.com/some_org/some_repo-py#egg=some_egg (from -r /requirements/athena.txt (line 2))
Cloning ssh://git#github.com/some_org/some_repo to /tmp/pip-build-jx3xzcel/athena
error: cannot run ssh: No such file or directory
fatal: unable to fork
Command "git clone -q ssh://git#github.com/some_org/some_repo /tmp/pip-build-jx3xzcel/athena" failed with error code 128 in None
You are using pip version 9.0.3, however version 19.0.3 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.
The command '/bin/sh -c pip3 install -r /requirements/athena.txt' returned a non-zero code: 1
Makefile:109: recipe for target 'build' failed
It seems that I do not have the ssh installed in the container, hence, trying to install it.
I have already tried with the commands available on various pages to install ssh on Debian, none of them have worked. Those commands include installing openssh-server and openssh-client via apt-get
RUN apt-get install -yqq openssh-server
I expect to have ssh installed and this step in the dockerfile to be a successful one but instead, I am getting the following error:
Step 20/38 : RUN apt-get install openssh-server
---> Running in e63d8d044b88
Reading package lists...
Building dependency tree...
Reading state information...
E: Unable to locate package openssh-server
The command '/bin/sh -c apt-get install openssh-server' returned a non-zero code: 100
make: *** [dev] Error 100

yum install not working from Dockerfile

I was trying to create a Docker Image for ProxySQL . Following is my DockerFile
FROM rhel7:latest
USER root
MAINTAINER Ques Zama
# Update the image with the latest packages (recommended)
RUN yum update -y; yum clean all
# Update image
RUN yum-config-manager --enable proxysql_repo
# Install ProxySQL
RUN yum install proxysql -y
# Expose ProxySQL Port 6034
EXPOSE 6034
# Start the service
CMD /etc/init.d/service start proxysql
I was trying to build the image with below command
sudo docker build --no-cache -t zama_proxysql .
But I can it is not able to install the proxysql package using yum command as mentioned in Dockerfile . Following is the message below
Step 6 : RUN yum install proxysql -y
---> Running in 54cc1ae88ba3
Loaded plugins: ovl, product-id, search-disabled-repos, subscription-manager
No package proxysql available.
Error: Nothing to do
The command '/bin/sh -c yum install proxysql -y' returned a non-zero code: 1
If I execute the command yum install proxysql in commandline , it works fine . But from Dockerfile , it could not find the package. Please note that I have already enabled the repo for proxysql in /etc/yum.repos.d
Any suggestions to resolve the issue
Try adding the repo manually first instead of using yum-config-manager :
cat <<EOF | tee /etc/yum.repos.d/proxysql.repo
[proxysql_repo]
name= ProxySQL YUM repository
baseurl=http://repo.proxysql.com/ProxySQL/proxysql-1.4.x/centos/\$releasever
gpgcheck=1
gpgkey=http://repo.proxysql.com/ProxySQL/repo_pub_key
EOF
This works properly on a FROM centos:7 image.

Run "From .." docker image inside Dockerfile

I'm building a image that builds a Jenkins and I try to use a plugin over the Jenkins when it is running, so, I need get run Jenkins before my plugin execution.
I execute it like docker build -t dockerfile and the error wich I am obtaining:
jenkins.JenkinsException: Error in request: [Errno 99]
Cannot assign requested address
I think the problem is when the plugin is executed it guess Jenkins is running and not.
FROM foxylion/jenkins
MAINTAINER Mishel Uchuari <dmuchuari#hotmail.com>
RUN /usr/local/bin/install-plugins.sh workflow-remote-loader workflow-aggregator build-pipeline-plugin
ENV JENKINS_USER replicate
ENV JENKINS_PASS replicate
USER root
RUN apt-get -y update && apt-get -y upgrade
RUN apt-get install -y apt-utils
RUN apt-get install -y python-pip
RUN apt install -y linuxbrew-wrapper
RUN useradd someuser -m -s /bin/bash
USER someuser
RUN chmod -R 777 /home/someuser
RUN brew install libyaml
USER root
RUN apt-get install build-essential
RUN apt-get -y update && apt-get -y upgrade
RUN pip install jenkins-job-builder==2.0.0.0b2
RUN pip install PyYAML python-jenkins
RUN mkdir /etc/jenkins_jobs/
COPY jenkins_jobs.ini /etc/jenkins_jobs/
COPY scm_pipeline.yaml /etc/jenkins_jobs/
RUN jenkins-jobs --conf /etc/jenkins_jobs/jenkins_jobs.ini update /etc/jenkins_jobs/scm_pipeline.yaml
I had the same issue myself when using it under Docker:
File "/src/.tox/py27/local/lib/python2.7/site-packages/jenkins_jobs/builder.py", line 124, in get_plugins_info
raise e
JenkinsException: Error in request: [Errno 99] Cannot assign requested address
That was caused when it tries to retrieve the list of plugins, I went overriding plugins_info to short circuit the code path:
jjb = JenkinsJobs(args=['test', config_dir, '-o', output_dir])
jjb.builder['plugins_info'] = [] # prevents 99 cannot assign requested address
jjb.execute()
I had the issue with python 2.7.9 on Debian Jessie. If I remember correctly that is no more an issue with a later python version eg 2.7.13 from Debian Stretch.
(the patch on which I encountered the issue):
https://gerrit.wikimedia.org/r/#/c/380929/8/tests/test_integration.py
RUN brew install libyaml
brew is a package manager for Mac OS X. Also PyYAML gracefully skip compilation when the lib is not availble. So you probably do not need that one. And I guess it would work without installing build-essential.
RUN pip install jenkins-job-builder==2.0.0.0b2
RUN pip install PyYAML python-jenkins
I am surprised you have install PyYAML and python-jenkins explicitly. Supposedly installing jenkins-job-builder should install all the dependencies (eg PyYAML and python-jenkins).

Trying to execute easy_install or pip on docker build says command not found

I am trying to build a docker container based on amazonlinux which is sort of centos.
One of the packages I need is supervisor and it is not available on the official repos so I have to do it with easy_install or pip.
The problem is that, although I tried installing python-setuptools and python-pip, then when I try to do:
RUN easy_install supervisor
or
RUN pip install supervisor
It says the command doesn't exists
/bin/sh: easy_install: command not found
The command '/bin/sh -c easy_install supervisor' returned a non-zero code: 127
I tried with full path, but same result, and I see other dockerfiles people doing it like that on centos images.
After a while, I found the reason.
By default, yum was installing python26 and the easy_install script runs with python27, so I had to be calling easy_install-2.6 or install the python27 package
Not familiar with AWS's specific image, but for a general centos image, you'll need to install pip or easy_install with a yum command first, which requires the epel repository:
RUN yum -y install epel-release \
&& yum -y install python-pip python-setuptools \
&& yum clean all
Python documented the process in detail on their page here: https://packaging.python.org/install_requirements_linux/
There's also some documentation on this over at superuser: https://superuser.com/q/877759/587488

Resources