Deployment failed through docker - docker

We are facing issue while deploying docker image in our application through Jenkins. Please can anybody help me out here.
Step 12/20 : RUN php installer
---> Running in 253d14820221
[91m/bin/sh: php: command not found
[0mThe command '/bin/sh -c php installer' returned a non-zero code: 127
[Pipeline] }
[Pipeline] // dir
[Pipeline] }
[Pipeline] // stage
[Pipeline] }
[Pipeline] // node
[Pipeline] End of Pipeline
ERROR: script returned exit code 127
Finished: FAILURE
Attached docker file-
ENV BUILD_ARGS=""
RUN yum -y update
RUN yum -y install epel-release wget
RUN wget https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
RUN wget https://centos7.iuscommunity.org/ius-release.rpm
RUN rpm -Uvh ius-release*.rpm
RUN yum -y update
RUN yum -y install php56u php56u-opcache php56u-xml php56u-mcrypt php56u-gd php56u-devel php56u-mysql php56u-intl php56u-mbstring php56u-bcmath nodejs git make gcc*
RUN npm install -g gulp bower
RUN wget https://getcomposer.org/installer
RUN php installer
RUN php -r "unlink('composer-setup.php');"
RUN ["mv", "/composer.phar", "/usr/local/bin/composer"]
COPY build.sh build
RUN chmod +x build
COPY cleanup.sh cleanup
RUN chmod +x cleanup
VOLUME "/wordpress"
CMD /build
Thanks in Advance

Ok So I don't know your build stage so I take the base image as centos. Looks like you have a missing enabled remi repo. May be you can try enabling remi repo and installing latest remi release too, So below two command you may need to add in your Dockerfile: RUN yum -y install http://rpms.remirepo.net/enterprise/remi-release-7.rpm and RUN yum-config-manager --enable remi-php56 and see if that works for you. Also, you notice php56u altered to php.
FROM centos
ENV BUILD_ARGS=""
RUN yum -y update
RUN yum -y install epel-release wget
RUN wget https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
RUN wget https://centos7.iuscommunity.org/ius-release.rpm
RUN yum -y install http://rpms.remirepo.net/enterprise/remi-release-7.rpm
RUN rpm -Uvh ius-release*.rpm
RUN yum -y update
RUN yum-config-manager --enable remi-php56
RUN yum -y install php php-opcache php-xml php-mcrypt php-gd php-devel php-mysql php-intl php-mbstring php-bcmath nodejs git make gcc*
RUN npm install -g gulp bower
RUN wget https://getcomposer.org/installer
RUN php installer

Related

failed to solve with frontend dockerfile.v0: failed to build LLB: executor failed

My Dockerfile
FROM centos:7
# Install Apache
RUN yum -y update
RUN yum -y install httpd httpd-tools
# Install EPEL Repo
RUN yum install https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
RUN yum install http://rpms.remirepo.net/enterprise/remi-release-7.rpm
# Install PHP
RUN yum install yum-utils
RUN yum-config-manager --enable remi-php73
RUN yum install php php-mcrypt php-cli php-gd php-curl php-mysql php-ldap php-zip php-fileinfo
# Update Apache Configuration
RUN sed -E -i -e '/<Directory "\/var\/www\/html">/,/<\/Directory>/s/AllowOverride None/AllowOverride All/' /etc/httpd/conf/httpd.conf
RUN sed -E -i -e 's/DirectoryIndex (.*)$/DirectoryIndex index.php \1/g' /etc/httpd/conf/httpd.conf
EXPOSE 80
# Start Apache
CMD ["/usr/sbin/httpd","-D","FOREGROUND"]
When I want to build this image I get
failed to solve with frontend dockerfile.v0: failed to build LLB: executor failed running [/bin/sh -c yum install https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm]: runc did not terminate successfully
How can build a docker image with centos apache and PHP 73?
remove the three lines
# Install EPEL Repo
RUN yum install https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
RUN yum install http://rpms.remirepo.net/enterprise/remi-release-7.rpm
those commands don't exist, I suspect you tried to copy instruction for dnf and replaced dnf with yum, that won't work.
And anyways you don't need those.
If you do need them, you can try
wget https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
wget https://rpms.remirepo.net/enterprise/remi-release-7.rpm
rpm -Uvh remi-release-7.rpm epel-release-latest-7.noarch.rpm
or maybe
RUN yum -y update; \
yum install -y epel-release; \
rpm -Uvh http://rpms.remirepo.net/enterprise/remi-release-7.rpm

Docker, sbt - cannot install sbt with centos docker image

I would like to have sbt in my docker image. I created a Dockerfile base on centos:centos8 image:
FROM centos:centos8
ENV SCALA_VERSION 2.13.1
ENV SBT_VERSION 0.13.18
RUN yum install -y epel-release
RUN yum update -y && yum install -y wget
RUN wget -O /usr/local/bin/sbt-launch.jar http://repo.typesafe.com/typesafe/ivy-releases/org.scala-sbt/sbt-launch/$SBT_VERSION/sbt-launch.jar
WORKDIR /root
EXPOSE 8080
RUN sbt compile
CMD sbt run
And also I need to have sbt installed here, but when I ran this script I got an error:
Step 10/11 : RUN sbt compile
---> Running in 0aadcd774ba0
/bin/sh: sbt: command not found
I cannot understand why sbt could not been found. Is it a good way to achieve what I need or I should try other one? But I need to do it with centos
EDIT:
Finally it works after help from answer below. Working script looks like:
FROM centos:centos8
ENV SBT_VERSION 0.13.17
RUN yum install -y java-11-openjdk && \
yum install -y epel-release && \
yum update -y && yum install -y wget && \
wget http://dl.bintray.com/sbt/rpm/sbt-$SBT_VERSION.rpm && \
yum install -y sbt-$SBT_VERSION.rpm
WORKDIR /root
EXPOSE 8080
RUN sbt compile
CMD sbt run
You would need to install sbt inside your Dockerfile. Here is an example:
FROM centos:centos8
ENV SCALA_VERSION 2.13.1
ENV SBT_VERSION 0.13.17
RUN yum install -y epel-release
RUN yum update -y && yum install -y wget
# INSTALL JAVA
RUN yum install -y java-11-openjdk
# INSTALL SBT
RUN wget http://dl.bintray.com/sbt/rpm/sbt-${SBT_VERSION}.rpm
RUN yum install -y sbt-${SBT_VERSION}.rpm
RUN wget -O /usr/local/bin/sbt-launch.jar http://repo.typesafe.com/typesafe/ivy-releases/org.scala-sbt/sbt-launch/$SBT_VERSION/sbt-launch.jar
WORKDIR /root
EXPOSE 8080
RUN sbt compile
CMD sbt run
Note: I did not see the version you had in your env variable (0.13.18) so I changed it to 0.13.17.
I ran into an issue where bintray.com was returning 403 randomly. I'm assuming it might be some kind of traffic throttle. Added the rpm file locally.
COPY sbt-0.13.18.rpm /
RUN yum install -y sbt-0.13.18.rpm

Dockerfile to create an image to be used as an container agent in jenkins

I am trying to use a node agent container in Jenkins to run npm instructions on it. So that, I am creating a Dockerfile to get a valid image with ssh and nodejs. The executor runs fine, but when I use npm it says that it doesn't know the command.
The same problem happens when (after building the dockerfile) I do docker exec -it af5451297d85 bash and after that, inside the container, I try to do npm --v (for example).
# This Dockerfile is used to build an image containing an node jenkins agent
FROM node:9.0
MAINTAINER Estefania Castro <estefania.castro#luceit.es>
# Upgrade and Install packages
RUN apt-get update && apt-get -y upgrade && apt-get install -y git openssh-server
# Install NGINX to test.
RUN apt-get install nginx -y
# Prepare container for ssh
RUN mkdir /var/run/sshd && adduser --quiet jenkins && echo "jenkins:jenkins" | chpasswd
RUN npm install
ENV CI=true
EXPOSE 22
CMD ["/usr/sbin/sshd", "-D"]
I would like to run npm instructions like npm install, npm publish, ... to manage my project in a jenkinsfile. Could anyone help?
Thanks
I have already solved the problem (after two weeks haha).
FROM jenkins/ssh-slave
# Install selected extensions and other stuff
RUN apt-get update && apt-get -y --no-install-recommends install && apt-get clean
RUN apt-get install -y curl
# Install nodejs
RUN curl -sL https://deb.nodesource.com/setup_8.x | bash -
RUN apt-get install -y nodejs && apt-get install -y nginx

Why am I getting Unable to correct problems, you have held broken packages

Trying to run Dockerfile and it fails at installing npm.
ERROR:
Unable to correct problems, you have held broken packages.
The command '/bin/sh -c apt-get install -y npm' returned a non-zero code: 100
Dockerfile:
FROM ubuntu:14.04
MAINTAINER Giacomo Vacca "giacomo.vacca#gmail.com"
ENV REFRESHED_AT 2015-01-19
ENV DEBIAN_FRONTEND noninteractive
RUN apt-get autoremove
RUN npm -v
RUN apt-get update
RUN apt-get upgrade -y
RUN apt-get install --yes curl
RUN curl --silent --location http://deb.nodesource.com/setup_0.10 | sudo bash -
RUN apt-get install -y nodejs
RUN apt-get install --yes build-essential
RUN rm /usr/bin/node
# needs this to find the nodejs exec
RUN ln -s /usr/bin/nodejs /usr/bin/node
RUN apt-get install -y npm <--- FAIL
RUN /usr/bin/npm install socket.io#0.9.14
EXPOSE 8080
ENTRYPOINT ["/usr/bin/node", "/root/server.js"]
You don't need to install npm from the ubuntu distribution with:
RUN apt-get install -y npm
because it's already installed by the nodejs package from nodesource. You can check it with:
dpkg -L nodejs | grep "/usr/bin/npm"

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