makefile:513: pod/perlintern.pod Segmentation fault (core dumped) When installing specific perl version in dockerfile - docker

I am trying to install perl 5.12.3 onto a Fedora 33 Docker image in my dockerfile however when I attempt to build the image I am faced with this error:
/bin/sh: line 1: /dev/tty: No such device or address
make[1]: Leaving directory '/'
make[1]: [makefile:964: minitest] Error 1 (ignored)
./miniperl -Ilib autodoc.pl
make: *** [makefile:513: pod/perlintern.pod] Segmentation fault (core dumped)
This is how I am attempting to install it:
RUN wget https://www.cpan.org/authors/id/R/RJ/RJBS/perl-5.12.3.tar.gz
RUN tar -xzf perl-5.12.3.tar.gz
RUN perl-5.12.3/Configure -Dmksymlinks -des -Dprefix=/usr/local/ -d y &&\
make && \
make test && \
make install
RUN perl -v
I guess that the problem is that docker is running the build context with no stdin or tty. Does anyone know a fix for this? I tried to install perlbrew instead to accomplish this but that was already proving to have quite a few of its own issues. Thank you for any help or advice. I am open to any other methods to installing perl 5.12.3 in the image.

I was able to install Perl version 5.12.4 with perlbrew like this (building fedora:33 docker image from my Ubuntu 21.04 laptop):
Dockerfile:
FROM fedora:33
SHELL ["/bin/bash", "-c"]
RUN yum -y update \
&& yum -y install gcc gcc-c++ make curl \
vim wget zlib-devel openssl-devel bzip2 patch \
perl-CPAN perl-App-cpanminus
ARG user=root
ARG home=/$user
WORKDIR $home
USER $user
COPY entrypoint.sh .
RUN chmod +x entrypoint.sh
ENTRYPOINT ["./entrypoint.sh"]
entrypoint.sh:
curl -L https://install.perlbrew.pl | SHELL=/bin/bash bash
echo 'export PERLBREW_ROOT=$HOME/perl5/perlbrew' >> .bashrc
echo 'source $PERLBREW_ROOT/etc/bashrc' >> .bashrc
export PERLBREW_ROOT=$HOME/perl5/perlbrew
source $PERLBREW_ROOT/etc/bashrc
perlbrew install --notest --noman perl-5.12.4
perlbrew install-cpanm
perlbrew switch perl-5.12.4
perl --version
exec bash

Related

GUI menu in docker container freezes (ubuntu parent image)

I've been trying to run a docker container including the esp8266 toolchain and ESP8266_RTOS_SDK.
After the Dockerfile is done the 'Espressif IoT Menu' pops up but freezes instantly and I cant control anything. Screenshot of the menu. I thought maybe I had to run the container endlessly, but it didn't help either. I tried this command: RUN tail -f /dev/null.
What else I thought is that the container might be missing some programs for a terminal?
Here is my Dockerfile (first time working with docker):
FROM ubuntu:latest
# -------------------------- TOOLCHAIN --------------------------------------
WORKDIR /
RUN apt-get update && apt-get install -y software-properties-common
RUN apt update && add-apt-repository universe
RUN apt-get -y install gcc wget git make libncurses-dev flex bison gperf python3 python3-serial python3-pip
RUN mkdir -p downloads esp8266
ADD https://dl.espressif.com/dl/xtensa-lx106-elf-linux64-1.22.0-100-ge567ec7-5.2.0.tar.gz downloads
RUN cd esp8266;tar -xzf /downloads/xtensa-lx106-elf-linux64-1.22.0-100-ge567ec7-5.2.0.tar.gz
ENV PATH=/esp8266/xtensa-lx106-elf/bin:$PATH
# -------------------------- ESP8266_RTOS_SDK ---------------------------------
RUN cd esp8266;git clone https://github.com/espressif/ESP8266_RTOS_SDK.git
ENV IDF_PATH="/esp8266/ESP8266_RTOS_SDK"
RUN ln -s /usr/bin/python3 /usr/bin/python #otherwise python wont be found
ENV TERM xterm #otherwise "terminal unknown"
RUN python3 -m pip install --user -r $IDF_PATH/requirements.txt
RUN cd esp8266;cp -r $IDF_PATH/examples/get-started/hello_world .
RUN cd /esp8266/hello_world;make menuconfig
I run the container with:
sudo docker build -f $(pwd)/dEsp8266 -t espenv .
The guide's I used:
For the toolchain: https://docs.espressif.com/projects/esp8266-rtos-sdk/en/latest/get-started/linux-setup.html
For the RTOS_SDK: https://docs.espressif.com/projects/esp8266-rtos-sdk/en/latest/get-started/index.html#get-started-get-esp-idf

Docker container: pip is not found even though I have set the PATH during building

I am new to docker container and I want to build an image with basic environment. Here is part of my Dockerfile:
FROM nvidia/cuda:10.0-cudnn7-devel-ubuntu18.04
ARG CTAGS_DIR=~/tools/ctags
ARG RIPGREP_DIR=~/tools/ripgrep
ARG ANACONDA_DIR=~/tools/anaconda
ARG NVIM_DIR=~/tools/nvim
ARG NVIM_CONFIG_DIR=~/.config/nvim
# Install common dev tools
RUN apt-get update --allow-unauthenticated \
&& apt-get install --allow-unauthenticated -y git curl autoconf pkg-config zsh
# Install anaconda
COPY ./packages/Anaconda3-2019.07-Linux-x86_64.sh /tmp/anaconda.sh
RUN chmod u+x /tmp/anaconda.sh \
&& bash /tmp/anaconda.sh -b -p ${ANACONDA_DIR} \
&& rm /tmp/anaconda.sh
ENV PATH=${ANACONDA_DIR}/bin:$PATH
# RUN echo $PATH && ls -l /root/tools/anaconda/bin|grep pip
RUN echo $PATH && ls -l ~/tools/anaconda/bin|grep pip
# Python packages
RUN pip install pynvim jedi pylint
The build process fails at the pip install step complaining that
/bin/sh: 1: pip: not found
The command '/bin/sh -c pip install pynvim jedi pylint' returned a non-zero code: 127
But the output of command
RUN echo $PATH && ls -l ~/tools/anaconda/bin|grep pip
is the following
~/tools/anaconda/bin:/usr/local/nvidia/bin:/usr/local/cuda/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
-rwxrwxr-x 1 root root 231 Sep 28 08:19 pip
which suggests that PATH is set and pip is foundable. I am not sure what is the problem here.
The only explanation is that PATH is set but is not correctly set. I do not know why.
Can someone experience explain what happened? What is wrong with my Dockerfile?
I don't see pip in the base image you used in your Dockerfile, you can check the offical Dockerfile, nor in the base image of nvidia/cuda, you can check the base image too 10.0-cudnn7-devel-ubuntu18.04
Installed pip and then try
FROM nvidia/cuda:10.0-cudnn7-devel-ubuntu18.04
RUN apt update && apt install python3-pip -y
RUN pip3 --version

Error in building docker image with perl installation

I am new to docker and i am trying to build the docker image with the perl installation but not sure exactly how to fix this error.
Dockerfile:
FROM amazonlinux
RUN mkdir /shared
RUN cd /shared
RUN yum -y install sudo
RUN cd /shared
RUN echo "Installing Perl."
RUN sudo yum -y update; yum -y install gcc
RUN yum -y install wget
RUN wget http://www.cpan.org/src/5.0/perl-5.22.1.tar.gz
RUN tar -xzf perl-5.22.1.tar.gz
RUN cd perl-5.22.1
RUN /shared/perl-5.22.1/Configure -des -Dprefix=/opt/perl-5.22.1/localperl
RUN make
RUN make test
RUN make install
RUN echo "Perl installation complete."
instead of /shared/perl-5.22.1/Configure i tried to give ./configure as well but i get the same error No such file or directory
Error:
/bin/sh: /shared/perl-5.22.1/Configure: No such file or directory
The command '/bin/sh -c /shared/perl-5.22.1/Configure -des -Dprefix=/opt/perl-5.22.1/localperl' returned a non-zero code: 127
ish-mac:testanalyse ish$
Can anyone tell me how to fix this issue.
Each Dockerfile RUN command runs in its own shell. So, when you do something like RUN cd /shared, the subsequent RUN commands will not be run inside that working directory.
What you want to use in this case is the WORKDIR instruction (https://docs.docker.com/engine/reference/builder/#workdir). You can also combine and shorten some things by taking advantage of the ADD instruction. A more concise Dockerfile to do what you are after might be:
FROM amazonlinux
WORKDIR /shared
RUN yum -y install gcc
ADD http://www.cpan.org/src/5.0/perl-5.22.1.tar.gz /shared
RUN tar -xzf perl-5.22.1.tar.gz
RUN /shared/perl-5.22.1/Configure -des -Dprefix=/opt/perl-5.22.1/localperl
RUN make -C /shared/perl-5.22.1
RUN make -C /shared/perl-5.22.1 test
RUN make -C /shared/perl-5.22.1 install
For example, the build context is already running as root so there is no need for sudo. With ADD we can add directly from URLs and no wget is required. And the make utility has a -C option to specify the working directory for make.
This should get you closer to what you are after. But the build still fails for other reasons (which you should probably open another question for if you are stuck).

Sudo make install permissions issue on Ubuntu 14.04

I have amended a script from https://github.com/jayrambhia/Install-OpenCV/blob/master/Ubuntu/2.4/opencv2_4_10.sh to try to install OpenCV 2.4.13 onto a vm running Ubuntu 14.04 where I have sudo permission. I'm new to openCV, cmake & make so any help getting this script to work would be appreciated as I have to install it on 20 vm's.
After a few minutes of running the script returns with an error saying can't
/bin/sh: 1: cd: can't cd to /home/myaccount/setups/OpenCV/opencv-2.4.13/build
and
make[2]: *** [3rdparty/libtiff/CMakeFiles/libtiff.dir/depend] Error 2
make[1]: *** [3rdparty/libtiff/CMakeFiles/libtiff.dir/all] Error 2
The last few lines of the output is included below and the script is before that.
Any ideas why the script wont complete successfully or how to correct the permissions issue?
Extra Details
I'm not sure if these are relevant but as I dig into the problem I'll update this section
cmake version 2.8
Makerfile mentions # The shell in which to execute make rules. SHELL
= /bin/sh but my terminal reports echo $0 as bash
when I run make install V=1 it builds 100% but then reports
-- Install configuration: "RELEASE" CMake Error at cmake_install.cmake:36 (FILE): file cannot create directory: /usr/local/include/opencv2. Maybe need administrative privileges
But when I run sudo make install V=1 I get can't cd error above
Adding Shebang #!/bin/bash to the start of my script didn't solve it
Running the script on a fresh ubuntu local machine alows the script to run but I need to get it running on the hosted vm
umask of setups folder (where script runs and creates a directory is 0022 . Permissions for setups folder is 755, group = Domain Users, Owner = myaccount Thats where the source files folder gets created as well as the build folder which is also 755 after it is created
Script
arch=$(uname -m)
if [ "$arch" == "i686" -o "$arch" == "i386" -o "$arch" == "i486" -o "$arch" == "i586" ]; then
flag=1
else
flag=0
fi
echo "Installing OpenCV 2.4.13"
mkdir OpenCV
cd OpenCV
echo "Removing any pre-installed ffmpeg and x264"
sudo apt-get -y remove ffmpeg x264 libx264-dev
echo "Installing unzip"
sudo apt-get -y install unzip
echo "Installing Dependenices"
sudo apt-get -y install libopencv-dev
sudo apt-get -y install build-essential checkinstall cmake pkg-config yasm
sudo apt-get -y install libtiff4-dev libjpeg-dev libjasper-dev
sudo apt-get -y install libavcodec-dev libavformat-dev libswscale-dev libdc1394-22-dev libxine-dev libgstreamer0.10-dev libgstreamer-plugins-base0.10-dev libv4l-dev
sudo apt-get -y install python-dev python-numpy
sudo apt-get -y install libtbb-dev libeigen3-dev
sudo apt-get -y install libqt4-dev libgtk2.0-dev
sudo apt-get -y install libfaac-dev libmp3lame-dev libopencore-amrnb-dev libopencore-amrwb-dev libtheora-dev libvorbis-dev libxvidcore-core-dev
sudo apt-get -y install x264 v4l-utils ffmpeg
sudo apt-get -y install libgtk2.0-dev
echo "Downloading OpenCV 2.4.13"
if ! [ -f "OpenCV-2.4.13.zip" ]; then
wget -O OpenCV-2.4.13.zip http://sourceforge.net/projects/opencvlibrary/files/opencv-unix/2.4.13/opencv-2.4.13.zip/download
fi
echo "Installing OpenCV 2.4.13"
if ! [ -d "opencv-2.4.13" ]; then
unzip OpenCV-2.4.13.zip
fi
rm OpenCV-2.4.13.zip
cd opencv-2.4.13
rm -rf build
mkdir build
cd build
cmake -D CUDA_ARCH_BIN=3.2 -D CUDA_ARCH_PTX=3.2 -D CMAKE_BUILD_TYPE=RELEASE -D CMAKE_INSTALL_PREFIX=/usr/local -D WITH_TBB=ON -D BUILD_NEW_PYTHON_SUPPORT=ON -D WITH_V4L=ON -D BUILD_TIFF=ON -D WITH_QT=ON -D WITH_OPENGL=ON ..
make -j$(nproc)
sudo make install
sudo sh -c 'echo "/usr/local/lib" > /etc/ld.so.conf.d/opencv.conf'
sudo ldconfig
echo "OpenCV 2.4.13 ready to be used"
Command Output
[100%] Build Java tests
Buildfile: /home/myaccount/setups/OpenCV/opencv-2.4.13/build/modules/java/test/.build/build.xml
build:
compile:
[mkdir] Created dir: /home/myaccount/setups/OpenCV/opencv-2.4.13/build/modules/java/test/.build/build/classes
[javac] Compiling 104 source files to /home/myaccount/setups/OpenCV/opencv-2.4.13/build/modules/java/test/.build/build/classes
jar:
[mkdir] Created dir: /home/myaccount/setups/OpenCV/opencv-2.4.13/build/modules/java/test/.build/build/jar
[jar] Building jar: /home/myaccount/setups/OpenCV/opencv-2.4.13/build/modules/java/test/.build/build/jar/opencv-test.jar
BUILD SUCCESSFUL
Total time: 6 seconds
[100%] Built target opencv_test_java
[sudo] password for myaccount:
Sorry, try again.
[sudo] password for myaccount:
/bin/sh: 1: cd: can't cd to /home/myaccount/setups/OpenCV/opencv-2.4.13/build
make[2]: *** [3rdparty/libtiff/CMakeFiles/libtiff.dir/depend] Error 2
make[1]: *** [3rdparty/libtiff/CMakeFiles/libtiff.dir/all] Error 2
make: *** [all] Error 2
OpenCV 2.4.13 ready to be used
myaccount#vm-20161023-002:~/setups$
What popped up into my head to explain the lack of permission problem: if your /home is on NFS, root may have nobody's permission on files there. There are quite a few related questions on StackExchange.
My solution would be not to try installing third-party software as root in the first place. Executing as root, your make install can do anything, including adding or overwriting files that are already managed by your software package manager. This may confuse the package manager or even render your system unusable. It's better to install the software somewhere else; /usr/local and /opt were created for this purpose. In order to make sure your installation procedure doesn't deviate from this, you can create a different user (which I call local), chown -R these directories to that user, and install using sudo -u local instead of sudoing to root. This will be fine for most installations, and should you run into one that tries to do something requiring root permissions (such as writing files to /etc or /usr/bin, restarting system services, doing tricky things with permissions, etc.), it will fail with an error message, allowing you to decide whether you want this before it has already happened. I have no idea whether OpenCV requires any such steps.

Docker CMD doesn't see installed components

I am trying to build a docker image using the following docker file.
FROM ubuntu:latest
# Replace shell with bash so we can source files
RUN rm /bin/sh && ln -s /bin/bash /bin/sh
# Update packages
RUN apt-get -y update && apt-get install -y \
curl \
build-essential \
libssl-dev \
git \
&& rm -rf /var/lib/apt/lists/*
ENV APP_NAME testapp
ENV NODE_VERSION 5.10
ENV SERVE_PORT 8080
ENV LIVE_RELOAD_PORT 8888
# Install nvm, node, and angular
RUN (curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.31.1/install.sh | bash -) \
&& source /root/.nvm/nvm.sh \
&& nvm install $NODE_VERSION \
&& npm install -g angular-cli \
&& ng new $APP_NAME \
&& cd $APP_NAME \
&& npm run postinstall
EXPOSE $SERVE_PORT $LIVE_RELOAD_PORT
WORKDIR $APP_NAME
EXPOSE 8080
CMD ["node", "-v"]
But I keep getting an error when trying to run it:
docker: Error response from daemon: Container command 'node' not found or does not exist..
I know node is being properly installed because if I rebuild the image by commenting out the CMD line from the docker file
#CMD ["node", "-v"]
And then start a shell session
docker run -it testimage
I can see that all my dependencies are there and return proper results
node -v
v5.10.1
.....
ng -v
angular-cli: 1.0.0-beta.5
node: 5.10.1
os: linux x64
So my question is. Why is the CMD in Dockerfile not able to run these and how can I fix it?
When using the shell to RUN node via nvm, you have sourced the nvm.sh file and it will have a $PATH variable set in it's environment to search for executable files via nvm.
When you run commands via docker run it will only inject a default PATH
docker run <your-ubuntu-image> echo $PATH
docker run <your-ubuntu-image> which node
docker run <your-ubuntu-image> nvm which node
Specifying a CMD with an array execs a binary directly without a shell or a $PATH to lookup.
Provide the full path to your node binary.
CMD ["/bin/node","-v"]
It's better to use the node binary rather than the nvm helper scripts due to the way dockers signal processing works. It might be easier to use the node apt packages in docker rather than nvm.

Resources