How to install man pages on an ubuntu docker image? - docker

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

Related

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

Docker build stops on software-properties-common when run with `apt update`

I have 2 dockerfiles:
FROM ubuntu:20.04
RUN apt-get update && apt-get install -y \
software-properties-common \
python3
FROM ubuntu:20.04
RUN apt-get update
RUN apt-get install -y software-properties-common
RUN apt-get update && apt-get install -y \
python3
The thing is: when I run the first of them (with docker build) the build process hangs on:
The software-properties-common package is asking me about the geographical area - I cannot provide any input, it is not allowed when building images, I suppose.
However, when I build the second dockerfile, this problem does not occur. I'm curious - why is that?
Add the following line in your Dockerfile and build again.
RUN DEBIAN_FRONTEND=noninteractive apt-get install -y tzdata
I found that running
ln -fs /usr/share/zoneinfo/UTC /etc/localtime
before setting DEBIAN_FRONTEND=noninteractive worked for me. (You'd want to replace the bit after zoneinfo with whatever is applicable for you.)
If you need it to be set dynamically, [this answer] (https://stackoverflow.com/a/63153978/1995015) suggests calling out to a website that can provide that.

Cannot install php, apache and postgres on ubuntu base image in dockerfile

I started studying docker recently and wanted to install php, apache and postgres in a ubuntu base image. But cannot run it after build.
Here is my Dockerfile
FROM ubuntu:16.04
RUN apt-get update
RUN apt-get -qq -y install curl
RUN apt-get -y install apache2
RUN apt-get -y install php7.0
RUN apt-get -y install libapache2-mod-php7.0
RUN apt-get -y install php7.0-mysql
RUN apt-get -y install php7.0-pgsql
RUN apt-get -y install php7.0-gd
RUN apt-get -y install php-pear
RUN apt-get -y install php7.0-curl
COPY . /var/www/html
EXPOSE 80
Can you please help me?
Thanks.
there are several issues here. First of all, I have the impression that you're mixing up docker and virtual machines. For this I suggest to go and read what are the differences.
Concerning your question, the problem is that the base image (ubuntu:16.04) has CMD bash (or something similar, I really didn't check) and therefore php is not considered.
In order to start apache, you should append the following:
CMD . /etc/apache2/envvars && /usr/sbin/apache2ctl -DFOREGROUND
Anyway, I'd suggest you give a check to the php official image.

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

Supervisor is not starting up

I am following cloudera cdh4 installation guide.
My base file
FROM ubuntu:precise
RUN apt-get update -y
#RUN apt-get install -y curl
RUN apt-get install -y software-properties-common python-software-properties
RUN add-apt-repository ppa:webupd8team/java
RUN apt-get update -y
RUN echo debconf shared/accepted-oracle-license-v1-1 select true | \
debconf-set-selections
RUN apt-get install -y oracle-java7-installer
#Checking java version
RUN java -version
My hadoop installation file
java_ubuntu is the image build from my base file.
FROM java_ubuntu:latest
RUN apt-get update -y
RUN apt-get install -y curl
RUN curl http://archive.cloudera.com/cdh4/one-click-install/precise/amd64/cdh4-repository_1.0_all.deb > cdh4-repository_1.0_all.deb
RUN dpkg -i cdh4-repository_1.0_all.deb
RUN curl -s http://archive.cloudera.com/cdh4/ubuntu/precise/amd64/cdh/archive.key | apt-key add -
RUN apt-get update -y
RUN apt-get install -y hadoop-0.20-conf-pseudo
#Check for /etc/hadoop/conf.pseudo.mrl to verfiy hadoop packages
RUN echo "dhis"
RUN dpkg -L hadoop-0.20-conf-pseudo
Supervisor part
hadoop_ubuntu is the image build from my hadoop installation docker file
FROM hadoop_ubuntu:latest
USER hdfs
RUN hdfs namenode -format
USER root
RUN apt-get install -y supervisor
RUN echo "[supervisord] nodameon=true [program=namenode] command=/etc/init.d/hadoop-hdfs-namenode -D" > /etc/supervisorconf.d
CMD ["/usr/bin/supervisord"]
Program is successfully build. But namenode is not starting up? How to use supervisor?
You have your config in /etc/supervisorconf.d and I don't believe that's the right location.
It should be /etc/supervisor/conf.d/supervisord.conf instead.
Also it's easier to maintain if you make a file locally and then use the COPY instruction to put it in the image.
Then as someone mentioned you can connect to the container after it's running (docker exec -it <container id> /bin/bash) and then run supervisorctl to see what's running and what might be wrong.
Perhaps you need line breaks in your supervisor.conf. Try hand crafting one and COPY it into your dockerfile for testing.
Docker and supervisord

Resources