/bin/sh: 1: ./configure: not found - dockerfile /bin/sh: 1: ./configure: not found - dockerfile apache apache

/bin/sh: 1: ./configure: not found - dockerfile


Dockerd will run a new container for every instruction except FROM in Dockerfile, so

RUN cd cosign-masterRUN autoconfRUN ./configure --enable-apache2=`which apxs`

three commands will be executed in three standalone containers, so cd cosign-master command can NOT change the PWD environment for next containers.You can use the absolute path or execute the associated commands in ONE container, which means in ONE instruction.

RUN cd cosign-master \    && autoconf \    && ./configure --enable-apache2=`which apxs` \    && make \    && make install

PS:

  1. should use one instruction to execute more commands to reduce the number of layers, because each instruction will generate a new layer.
  2. should clean up the intermediate files or softwares to reduce the size of final image.

For examples:

FROM ubuntu:16.04FROM python:3.5ENV PYTHONUNBUFFERED=1 \    APACHE_RUN_USER=www-data \    APACHE_RUN_GROUP=www-data \    APACHE_LOG_DIR=/var/log/apache2 \    APACHE_LOCK_DIR=/var/lock/apache2 \    APACHE_PID_FILE=/var/run/apache2.pidRUN set -ex \    && cat /etc/passwd \    && cat /etc/group \    && apt-get update \    && export COMPILE_TOOLS="autoconf libssl-dev openssl" \    && apt-get install -y \               apache2 \               apache2-dev \               libapache2-mod-wsgi-py3 \               ${COMPILE_TOOLS} \    && wget https://github.com/umich-iam/cosign/archive/master.tar.gz -O /tmp/cosign-master.tar.gz \    && tar xfz /tmp/cosign-master.tar.gz -C=/tmp \    && cd /tmp/cosign-master \    && autoconf \    && ./configure --enable-apache2=$(which apxs) \    && make \    && make install \    && mkdir -p /var/cosign/filter \    && chown www-data:www-data /var/cosign/filter \    && apt-get purge -y ${COMPILE_TOOLS} \    && rm -rf /var/lib/apt/lists/* \              /tmp/cosign-master.tar.gz \              /tmp/cosign-master/*WORKDIR /code# The Umich IAM copy of Cosign includes Apache 2.4 supportCOPY requirements.txt /code/COPY . /code# Update the default apache site with the config we created.COPY 000-default.conf /etc/apache2/sites-enabled/000-default.confRUN mkdir /var/run/sshd \    && pip install -r requirements.txt \    && chown -R root:www-data /var/www \    && chmod u+rwx,g+rx,o+rx /var/www \    && find /var/www -type d -exec chmod u+rwx,g+rx,o+rx {} + \    && find /var/www -type f -exec chmod u+rw,g+rw,o+r {} +EXPOSE 80#essentially: CMD ["/usr/sbin/apachectl", "-D", "FOREGROUND"]CMD ["/tmp/start.sh"]

This will:

  1. reduce layers of your image from about 35 to just 9!
  2. reduce the size of your image immensely, maybe only one third of your origin image.
  3. maybe a little difficult to read :)

Hope this helps!