I am trying to run this below command inside a docker container
(centos 7 as the base image)
ssh-keygen -t rsa -N ""
and I get this error:
ssh-keygen: command not found
And this is the Dockerfile I used to build the container
FROM centos:7
ENV VER "0.12.9"
RUN yum update -y && yum install wget -y && yum install unzip -y
RUN yum install epel-release -y && yum install ansible -y
RUN wget https://releases.hashicorp.com/terraform/${VER}/terraform_${VER}_linux_amd64.zip
RUN unzip terraform_${VER}_linux_amd64.zip
RUN mv terraform /usr/local/bin/
RUN rm -rf terraform_${VER}_linux_amd64.zip
Can someone help me, Please?
ssh-keygen is command provided by OpenSSH, you need to install it.
Add yum install openssh-clients -y to your Dockerfile.
FROM centos:7
ENV VER "0.12.9"
RUN yum update -y && yum install wget -y && yum install unzip -y
RUN yum install epel-release -y && yum install ansible -y && yum install openssh-clients -y
RUN wget https://releases.hashicorp.com/terraform/${VER}/terraform_${VER}_linux_amd64.zip
RUN unzip terraform_${VER}_linux_amd64.zip
RUN mv terraform /usr/local/bin/
RUN rm -rf terraform_${VER}_linux_amd64.zip
Related
I have the below dockerfile that needs to run a owasp bash file for its intallation.
This .sh file needs multiple inputs(like 1, Y, enter) from the user for the completion of installation.
How do I provide these inputs from dockerfile or is there a way to skip these inputs and continue the installation.
This dockerfile is a part of the docker-compose.
Below is thew dockerfile
FROM ubuntu:20.04
RUN apt-get update && apt-get upgrade -y && apt-get clean
RUN apt-get install python3-pip -y
RUN apt-get install vim -y
ARG DEBIAN_FRONTEND=noninteractive
ENV TZ=Indian
# Install OpenJDK-8
RUN apt-get install -y openjdk-8-jdk && \
apt-get install -y ant && \
apt-get clean;
# Fix certificate issues
RUN apt-get update && \
apt-get install ca-certificates-java && \
apt-get clean && \
update-ca-certificates -f
ENV JAVA_HOME /usr/lib/jvm/java-8-openjdk-amd64/
RUN export JAVA_HOME
RUN apt-get install wget -y && \
apt-get install unzip -y && \
apt-get install zip -y
RUN mkdir /home/owasp
RUN wget -c https://github.com/zaproxy/zaproxy/releases/download/v2.11.0/ZAP_2_11_0_unix.sh -P /home/owasp
RUN chmod u+x /home/owasp/ZAP_2_11_0_unix.sh
RUN ./home/owasp/ZAP_2_11_0_unix.sh
Use the Linux Package : https://github.com/zaproxy/zaproxy/releases/download/v2.11.0/ZAP_2.11.0_Linux.tar.gz
That has the same contents but is just a gziped tar file :)
Full list of ZAP downloads available is on https://www.zaproxy.org/download/
Or you can always extend our docker images https://www.zaproxy.org/docs/docker/
To provide input for command use some input generator and pipe it with your command.
Typical example is using command yes which provides endless stream of "y" on output:
RUN yes|./own-shell-scrpit.sh
You can run printf 'y\n1abc\nxxx' and pipe it. "\n" in printf states for newline (or enter).
I would suggest adding a ENTRYPOINT so it by default will invoke your bash script, but it gives the flexibily to the end user to pass different arguments. See the official docs. Keep in mind the CMD provided in a Dockerfile is a default command. You override it by passing any other value.
FROM ubuntu:20.04
ENV DEBIAN_FRONTEND=noninteractive
ENV TZ=Indian
RUN apt-get update && apt-get upgrade -y && apt-get clean
RUN apt-get install python3-pip -y
RUN apt-get install vim -y
# Install OpenJDK-8
RUN apt-get install -y openjdk-8-jdk && \
apt-get install -y ant && \
apt-get clean;
# Fix certificate issues
RUN apt-get update && \
apt-get install ca-certificates-java && \
apt-get clean && \
update-ca-certificates -f
ENV JAVA_HOME /usr/lib/jvm/java-8-openjdk-amd64/
RUN export JAVA_HOME
RUN apt-get install wget -y && \
apt-get install unzip -y && \
apt-get install zip -y
RUN mkdir /home/owasp
RUN wget -c https://github.com/zaproxy/zaproxy/releases/download/v2.11.0/ZAP_2_11_0_unix.sh -P /home/owasp
RUN chmod u+x /home/owasp/ZAP_2_11_0_unix.sh
ENTRYPOINT ./home/owasp/ZAP_2_11_0_unix.sh
CMD ['--some', '--default', '--args']
You can even choose to pass default flags on build. So your script will then always run with default flags you provided on docker build --build-args DEFAULT_PARAMS=--foo, unless you override it:
ARGS DEFAULT_PARAMS
FROM ubuntu:20.04
ENV DEFAULT_PARAMS=${DEFAULT_PARAMS}
ENV DEBIAN_FRONTEND=noninteractive
ENV TZ=Indian
RUN apt-get update && apt-get upgrade -y && apt-get clean
RUN apt-get install python3-pip -y
RUN apt-get install vim -y
# Install OpenJDK-8
RUN apt-get install -y openjdk-8-jdk && \
apt-get install -y ant && \
apt-get clean;
# Fix certificate issues
RUN apt-get update && \
apt-get install ca-certificates-java && \
apt-get clean && \
update-ca-certificates -f
ENV JAVA_HOME /usr/lib/jvm/java-8-openjdk-amd64/
RUN export JAVA_HOME
RUN apt-get install wget -y && \
apt-get install unzip -y && \
apt-get install zip -y
RUN mkdir /home/owasp
RUN wget -c https://github.com/zaproxy/zaproxy/releases/download/v2.11.0/ZAP_2_11_0_unix.sh -P /home/owasp
RUN chmod u+x /home/owasp/ZAP_2_11_0_unix.sh
ENTRYPOINT ./home/owasp/ZAP_2_11_0_unix.sh
CMD ${DEFAULT_PARAMS}
I am getting multiple errors when I reduce layer in the following image file.
configure: error: in /root/xdebug': configure: error: no acceptable C compiler found in $PATH See config.log' for more details
Following Original file is not giving me any errors. it's only when I make the changes to the file. I think it has something to do with permissions and the way I'm adding steps.
FROM amazonlinux
ARG DOCKER_TYPE
ENV DOCKER_TYPE=$DOCKER_TYPE
ARG UID
RUN yum update -y
RUN yum install sudo -y
RUN sudo yum install git -y
RUN sudo amazon-linux-extras install php7.2 -y
RUN sudo yum install php-mbstring -y
RUN sudo yum install php-openssl -y
RUN sudo yum install php-pdo_mysql -y
RUN sudo yum install php-simplexml -y
RUN sudo yum install php-soap -y
RUN sudo yum install php-spl -y
RUN sudo yum install php-xsl -y
RUN sudo yum install php-zip -y
RUN sudo yum install php-libxml -y
RUN sudo yum install php-intl -y
RUN sudo yum install php-iconv -y
RUN sudo yum install php-hash -y
RUN sudo yum install php-gd -y
RUN sudo yum install php-dom -y
RUN sudo yum install php-curl -y
RUN sudo yum install php-ctype -y
RUN sudo yum install php-bcmath -y
RUN sudo yum install php-devel -y
RUN sudo yum groupinstall "Development tools" -y
# Xdebug
RUN cd /root/; git clone https://github.com/xdebug/xdebug.git; cd /root/xdebug/; ./rebuild.sh
Updated version
FROM amazonlinux
ARG DOCKER_TYPE
ENV DOCKER_TYPE=$DOCKER_TYPE
ARG UID
RUN yum update -y
RUN yum install sudo -y && sudo yum install -y \
git \
amazon-linux-extras install php7.2 \
php-mbstring \
php-openssl \
php-pdo_mysql \
php-simplexml \
php-soap \
php-spl \
php-xsl \
php-zip \
php-libxml \
php-intl \
php-iconv \
php-hash \
php-gd \
php-dom \
php-curl \
php-ctype \
php-bcmath \
php-devel \
groupinstall "Development tools"
# Xdebug
RUN cd /root/; git clone https://github.com/xdebug/xdebug.git; cd /root/xdebug/; ./rebuild.sh
You're replacing the line
RUN sudo amazon-linux-extras install php7.2
with an argument to yum install.
That's apparently something different.
You can probably fix it by adding && after git and starting a new sudo yum install for the following packages.
Indentation which clearly shows where a new command is started and where you just add more arguments to a command would help readability a lot.
Your updated dockerfile should look something like this:
FROM amazonlinux
ARG DOCKER_TYPE
ENV DOCKER_TYPE=$DOCKER_TYPE
ARG UID
RUN yum update -y && \
yum install sudo -y && \
sudo yum install git -y && \
sudo amazon-linux-extras install php7.2 -y && \
sudo yum install php-mbstring -y && \
sudo yum install php-openssl -y && \
sudo yum install php-pdo_mysql -y && \
sudo yum install php-simplexml -y && \
sudo yum install php-soap -y && \
sudo yum install php-spl -y && \
sudo yum install php-xsl -y && \
sudo yum install php-zip -y && \
sudo yum install php-libxml -y && \
sudo yum install php-intl -y && \
sudo yum install php-iconv -y && \
sudo yum install php-hash -y && \
sudo yum install php-gd -y && \
sudo yum install php-dom -y && \
sudo yum install php-curl -y && \
sudo yum install php-ctype -y && \
sudo yum install php-bcmath -y && \
sudo yum install php-devel -y && \
sudo yum groupinstall "Development tools" -y && \
sudo yum clean all
# Xdebug
RUN cd /root/; git clone https://github.com/xdebug/xdebug.git; cd /root/xdebug/; ./rebuild.sh
To change multiple "RUN" instructions you need to run them with && between them. The "\" character marks that the instruction continues in the next line.
I've also added
yum clean all
at the end of this single RUN instruction to keep your image layers smaller.
I am trying to build a docker image containing Nginx Web Server and PHP.
I am using a VM with centos 7
This is my Dockerfile
FROM remote-host
COPY ./conf/nginx.repo /etc/yum.repos.d/nginx.repo
RUN yum -y update && \
yum install -y epel-release && \
yum -y install nginx openssl --enablerepo=nginx && \
yum -y update && \
yum -y install https://centos7.iuscommunity.org/ius-release.rpm --nobest --skip-broken && \
yum -y install php71u-fpm php71u-cli && \
yum clean all
EXPOSE 80 443
VOLUME /var/www/html /var/log/nginx /var/log/php-fpm /var/lib/php-fpm
COPY ./conf/nginx.conf /etc/nginx/conf.d/default.conf
COPY ./bin/start.sh /start.sh
RUN chmod +x /start.sh
CMD /start.sh
This is the error output :
Problem: conflicting requests
- nothing provides epel-release = 7 needed by ius-release-2-1.el7.ius.noarch
================================================================================
Skip 1 Package
Nothing to do.
Complete!
Last metadata expiration check: 0:00:22 ago on Fri Dec 6 23:07:40 2019.
**No match for argument: php71u-fpm
No match for argument: php71u-cli
Error: Unable to find a match**
ERROR: Service 'web' failed to build: The command '/bin/sh -c yum -y update && yum install -y epel-release && yum -y install nginx openssl --enablerepo=nginx && yum -y update && yum -y install https://centos7.iuscommunity.org/ius-release.rpm --nobest --skip-broken && yum -y install php71u-fpm php71u-cli && yum clean all' returned a non-zero code: 1
Looks like epel-release package is missing.
Make sure CentOS Extras repository includes a package to install EPEL
You can check with below comands
yum search epel-release
yum info epel-release
the package family php71u is deprecated but can be downloaded by setting the repo to be "ius-archive" instead of "ius-release". like wise:
yum --enablerepo=ius-archive install php71u-fpm
I have create in docker 2 contains 1 to run the MSSQL server and the other a python container with the code to read data from an .xlsx file and inserting it into SQL server.
My Dockerfile has the below code :
FROM python:3.6-alpine
RUN apk update
RUN apk add gcc libc-dev g++ libffi-dev libxml2 unixodbc-dev mariadb-dev postgresql-dev
FROM continuumio/miniconda3
ADD test.py /
RUN apt-get update -y \
&& apt install python3 -y \
&& apt install python3-pip -y \
&& apt install python3-venv -y \
&& python3 -m venv venv
RUN apt-get -y install curl
**#Install FreeTDS and dependencies for PyODBC**
RUN apt-get update && apt-get install -y tdsodbc unixodbc-dev \
&& apt install unixodbc-bin -y \
&& apt-get clean -y
RUN apt-get update
RUN apt-get install -y tdsodbc unixodbc-dev
RUN apt install unixodbc-bin -y
RUN apt-get clean -y
RUN pip install pandas
RUN pip install pyodbc
RUN pip install DateTime
RUN pip install multiprocess
RUN pip install threaded
CMD [ "python", "./test.py" ]
It compiles successfully but fails every time i run the container with the below error :
pyodbc.Error: ('01000', "[01000] [unixODBC][Driver Manager]Can't open lib 'ODBC Driver 17 for SQL Server' : file not found (0) (SQLDriverConnect)")
I have been trying this for days but found no resolution.
Believe I need to install ODBC driver 17, if so how do I add it to my Dockerfile?
I'm building docker image with a Dockerfile:
FROM centos:centos7.1.1503
MAINTAINER foo <foo#bar.com>
ENV TZ "Asia/Shanghai"
ENV TERM xterm
RUN \
yum update -y && \
yum install -y epel-release &&\
yum update -y && \
yum install -y curl wget tar bzip2 unzip vim-enhanced passwd sudo yum-utils hostname net-tools rsync man && \
yum install -y gcc gcc-c++ git make automake cmake patch logrotate python-devel libpng-devel libjpeg-devel && \
yum install -y pwgen python-pip && \
yum clean all
and it show the error as below:
Error: libselinux conflicts with fakesystemd-1-17.el7.centos.noarch
If I change FROM centos:centos7.1.1503 to FROM centos:centos7,all will work fine. So ,what should I do to using centos7.1.1503
My Linux Distribution is Ubuntu 16.04.1 LTS and my docker version is 1.12.6.
Try running this inside the container you create, before any installation is made:
yum swap -y fakesystemd systemd && yum clean all
yum update -y && yum clean all
Or inside a Dockerfile at the begining before the first RUN you have tipped:
RUN yum swap -y fakesystemd systemd && yum clean all \
&& yum update -y && yum clean all
Hope was useful!