Issue installing scons in Dockerfile -- No match for argumet scons using yum - docker

I am trying to create a docker image from centos that uses scons.
The simple Dockerfile I am trying right now is:
FROM centos:latest
USER root
RUN yum update -y
RUN yum -y install scons
however, when I run docker build, I get the following error:
No match for argument: scons Error: Unable to find a match The command
'/bin/sh -c yum -y install scons' returned a non-zero code: 1
From what I understand I should be able to yum install scons, is there another way I need to do this in a Dockerfile?

I am not sure if this something to do with the base image, but this docker image is base on centos7 and it seems working.
FROM centos:centos7.6.1810
RUN yum update -y
RUN yum -y install epel-release && \
yum -y install scons
RUN scons --version

Related

How to add jdk17 in Docker run command in amazon extras in Dockerfile?

I am trying to use the amazon linux and installing amazon extras,
Here is my Dockerfile,
FROM amazonlinux:2
# Install CloudHSM client
RUN yum install -y https://s3.amazonaws.com/cloudhsmv2-software/CloudHsmClient/EL7/cloudhsm-client-3.4.4-1.el7.x86_64.rpm
# Install CloudHSM Java library
RUN yum install -y https://s3.amazonaws.com/cloudhsmv2-software/CloudHsmClient/EL7/cloudhsm-client-jce-3.4.4-1.el7.x86_64.rpm
# Install Java 11
RUN amazon-linux-extras install -y java-openjdk11
When I replace the run command with following
RUN amazon-linux-extras install -y java-openjdk17
It fails, I get error as java-openjdk17 not found. Please help.
# Install Java 11
RUN amazon-linux-extras install -y java-openjdk11
When I replace the run command with following
RUN amazon-linux-extras install -y java-openjdk17
It fails, I get error as java-openjdk17 not found. Please help.

Installing java 8 in centos 7 dockerfile

I just looked at this question: How to define OpenJDK 8 in CentOS based Dockerfile?.
I tried the suggested answers, but I'm not getting the expected results. Here are the contents of my DockerFile
FROM centos:7
RUN yum install -y \
java-1.8.0-openjdk \
java-1.8.0-openjdk-devel
ENV JAVA_HOME /etc/alternatives/jre
RUN yum install maven
RUN yum install curl
RUN yum install -y unzip
I am building the image via: docker build -t container_image:latest -f DockerFile.build .
Then when I run docker run -it {image_id} /bin/bash and perform java --version I get bash: java: command not found. Can someone help me see what I am doing wrong here?
Also, when I try to install the jdk from within the container via yum install java-1.8.0-openjdk I get the following
java --version
Unrecognized option: --version
Error: Could not create the Java Virtual Machine.
Error: A fatal exception has occurred. Program will exit.
This fixed it
FROM centos
RUN yum -y update
RUN yum -y remove java
RUN yum install -y \
java-1.8.0-openjdk \
java-1.8.0-openjdk-devel
RUN yum install -y maven
RUN yum install -y curl
RUN yum install -y unzip

Install Java runtime in Debian based docker image

I am trying to install the java runtime in a Debian based docker image (mcr.microsoft.com/dotnet/core/sdk:3.1-buster). According to various howtos this should be possible by running
RUN apt update
RUN apt-get install openjdk-11-jre
The latter command comes back with
E: Unable to locate package openjdk-11-jre
However according to https://packages.debian.org/buster/openjdk-11-jre the package does exist. What am I doing wrong?
Unsure from which image your are pulling. I used slim, Dockerfile.
from debian:buster-slim
ENV DEBIAN_FRONTEND=noninteractive
RUN mkdir -p /usr/share/man/man1 /usr/share/man/man2
RUN apt-get update && \
apt-get install -y --no-install-recommends \
openjdk-11-jre
# Prints installed java version, just for checking
RUN java --version
NOTE: If you don't run the mkdir -p /usr/share/man/man1 /usr/share/man/man2 you'll run into dependency problems with ca-certificates, openjdk-11-jre-headless etc. I've been using this fix provided by community, haven't really checked the permanent fix.

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

How to install a local rpm file when building docker instance?

I have following docker file, I want to specifically install a rpm file that is available on my disk as I am building docker instance. My invocation of rpm install looks like this. Command
RUN rpm -i chrpath-0.13-14.el7.x86_64.rpm fails.
Is there a way to install rpm file available locally to new Docker instance?
FROM centos:latest
RUN yum -y install yum-utils
RUN yum -y install python-setuptools
RUN easy_install supervisor
RUN mkdir -p /var/log/supervisor
RUN yum -y install which
RUN yum -y install git
# Basic build dependencies.
RUN yum -y install autoconf build-essential unzip zip
# Gold linker is much faster than standard linker.
RUN yum -y install binutils
# Developer tools.
RUN yum -y install bash-completion curl emacs git man-db python-dev python-pip vim tar
RUN yum -y install gcc gcc-c++ kernel-devel make
RUN yum -y install swig
RUN yum -y install wget
RUN yum -y install python-devel
RUN yum -y install ntp
RUN rpm -i chrpath-0.13-14.el7.x86_64.rpm
Put this line before your rpm -i command:
ADD /host/abs/path/to/chrpath-0.13-14.el7.x86_64.rpm /chrpath-0.13-14.el7.x86_64.rpm
Then you'll be able to do
RUN rpm -i chrpath-0.13-14.el7.x86_64.rpm
As and addendum to what others have written here, rather than using:
RUN rpm -i xyz.rpm
You might be better off doing this:
RUN yum install -y xyz.rpm
The latter has the advantages that (a) it checks the signature, (b) downloads any dependencies, and (c) makes sure YUM knows about the package. This last bit is less important than the other two, but it's still worthwhile.
Suppose you have your Dockerfile available at /opt/myproject/. Then first you have to put rpm inside /opt/myproject and then add
Add /xyz.rpm /xyz.rpm
RUN rpm -i xyz.rpm

Resources