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

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

Related

How to upgrade cURL to 7.71.0 in a docker image with centos7.x as the base

Title is pretty self explanatory, when using yum upgrade curl it doesn't upgrade curl beyond 7.29.0 witch is an issue because I need to use the --retry-all-errors flag in the docker images startup script.
Running the below commands solved my issue
sudo rpm -Uvh http://www.city-fan.org/ftp/contrib/yum-repo/rhel7/x86_64/city-fan.org-release-2-2.rhel7.noarch.rpm
sudo yum install -y yum-utils
sudo yum-config-manager --disable city-fan.org
sudo yum -y --enablerepo=city-fan.org install libcurl libcurl-devel
If using the city-fan repo is an issue for you, you can also use this script to install directly from curl.
sudo yum install wget gcc openssl-devel make -y
wget https://curl.haxx.se/download/curl-${VERSION}.tar.gz
tar -xzvf curl-${VERSION}.tar.gz
rm -f curl-${VERSION}.tar.gz
cd curl-${VERSION}
./configure --prefix=/usr/local --with-ssl
make
sudo make install
sudo ldconfig

Man pages not being installed in python docker image [duplicate]

I use the following Dockerfile to build an image and start a container. But once I am in the container, I still can not find manpages. Does anybody know how to solve this problem?
$ cat Dockerfile
FROM ubuntu
RUN apt -y update && apt -y upgrade
RUN apt-get -y install build-essential
RUN apt-get -y install vim
RUN apt-get -y install man
RUN apt-get -y install gawk
RUN apt-get -y install mawk
$ man man
No manual entry for man
See 'man 7 undocumented' for help when manual pages are not available.
$ find /usr/share/man /usr/local/share/man -type f
You need to make a change to your /etc/dpkg/dpkg.cfg.d/excludes within the container. You can do this in your Dockerfile with the following command:
RUN sed -i 's:^path-exclude=/usr/share/man:#path-exclude=/usr/share/man:' \
/etc/dpkg/dpkg.cfg.d/excludes
Then make another update to your Dockerfile to install the man pages
RUN apt-get update && \
apt-get install -y \
man \
manpages-posix
There is a easier way to enable the MAN command.
In terminal, just execute the command below:
unminimize
It will ask if you like to continue [Y/n]
Just press:
Y
It will take a while to finish all the processing.
After that, test this:
man man
Simple as that
Thanks to #kazushi

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

How to install man pages on an ubuntu docker image?

I use the following Dockerfile to build an image and start a container. But once I am in the container, I still can not find manpages. Does anybody know how to solve this problem?
$ cat Dockerfile
FROM ubuntu
RUN apt -y update && apt -y upgrade
RUN apt-get -y install build-essential
RUN apt-get -y install vim
RUN apt-get -y install man
RUN apt-get -y install gawk
RUN apt-get -y install mawk
$ man man
No manual entry for man
See 'man 7 undocumented' for help when manual pages are not available.
$ find /usr/share/man /usr/local/share/man -type f
You need to make a change to your /etc/dpkg/dpkg.cfg.d/excludes within the container. You can do this in your Dockerfile with the following command:
RUN sed -i 's:^path-exclude=/usr/share/man:#path-exclude=/usr/share/man:' \
/etc/dpkg/dpkg.cfg.d/excludes
Then make another update to your Dockerfile to install the man pages
RUN apt-get update && \
apt-get install -y \
man \
manpages-posix
There is a easier way to enable the MAN command.
In terminal, just execute the command below:
unminimize
It will ask if you like to continue [Y/n]
Just press:
Y
It will take a while to finish all the processing.
After that, test this:
man man
Simple as that
Thanks to #kazushi

PhantomJS server running in Docker container

I need to run PhantomJS server to generate images on demand. When I set this up on a standard Amazon Linux EC2 instance, it works fine.
However, I want to distribute it in a Docker container. Using the Amazon Linux base (http://docs.aws.amazon.com/AmazonECR/latest/userguide/amazon_linux_container_image.html) I include the following RPMS:
RUN \
yum update && \
yum install -y tar \
yum install -y bzip2 \
yum install -y freetype6 \
yum install -y fontconfig \
yum install -y freetype-devel \
yum install -y fontconfig-devel \
yum install -y libicu-devel \
yum install -y libpng-devel \
yum install -y libjpeg-devel \
yum install -y gperf \
yum install -y bison \
yum install -y flex \
yum install -y gcc \
yum install -y gcc-c++
And then set up the phantomjs server as I did on the standard EC2 instance.
When launched, this generates images, but the images are missing their text labels. I can't find any debug output, and I didn't write the original code to generate the image.
Could anyone suggest what might be missing from the Docker container? I didn't have to install any extra libraries in the EC2 instance to get it to work. I've also tried increasing the spec of the host instance image in case there were issues with RAM.
Sample broken image:
https://gm1.ggpht.com/RxVy2Q6KpRVRxSPCoVEupfnl2ieHY9dr9Vu8o9P4JOjw4FqVsEfPgW1leA59R8n2hNF9u6cmL3LLO3idArCWBiE1EFpIz5CI9n29z1_95sC0lesTy6oxkcIoBoHMFNdMNSqURW9Sc1Is8Sd1t-YWsQKgJvtUsotBmRaEOWSKr7JpyjY6stSl1xJiJ5enc7ccvKTkPcuFNMl_NQCrv9b44brzpFjO2y6ZDrfBZolFXc-hqXvbRFazsRd-IVFh4mENLxVmQpeqbRug-egBHV_LCmj0ohBToxT4_b6_pqZpim9MZR6KFCX7QDu-rGtlhpMeweeDZ8uRkPwYyZ48hiEAQpVPAfsHNQGHR_kcRSN7-3bKDZJKjvPtcQjn-5bR-AMwX5B8iqFGyLLaG4QeA7AykmPJ4LGrX8aboPRRSdkH9EdYwEa4wH4IogHa6m4-OobG1FLdEgnveHzVL4XkB3zesrKa3-t5TgdL8nP9xTLaId2uLdqVO39QPTxKGrutyFJst1WhsdoUiBYhLD4JQZW0COBaQB9Kdu-anLpgaZ4oObrtqfzVRxrjdL5s7Qf_FagPtyZiSra2RfF3uDEpjRi0w3BSd8P-PvC2jmTqvuMz4rK-Go9pLLU1Dsqz3mR7p70yE7SVTzVy61YJLYT_NW3vAgHIir_HuJ4fpA3vg8qc2WGgUbOB83QtBsxQoIvu0oyIqq7k7pYzJ6SKCA=s0-l75-ft-l75-ft
I eventually resolved this by using an Ubuntu base rather than an Amazon Linux base. Never determined what was missing from Amazon Linux.

Resources