ShahRokh
ShahRokh

Reputation: 1025

Docker returned a non-zero code: 28 when install composer

I use docker-compose to handle my application. But when I build the Dokerfile, it returns a non-zero code (28) as error after 5 minutes, at the curl composer step. Our office is connected to the internet via a VPN, and our download speed is limited to 120k max.

Screenshot of the error

Dockerfile:

# ubuntu strech
FROM ubuntu:18.04

# debian no intract
ENV DEBIAN_FRONTEND noninteractive

RUN sed -i 's/archive.ubuntu.com/ir.archive.ubuntu.com/g' /etc/apt/sources.list

RUN export COMPOSER_CACHE_DIR=/tmp/composer ; \
    export LANG=en_US.utf8 ; \
    export LC_ALL=C.UTF-8 ;

# Update and upgrade
RUN apt-get update -y \
  && apt-get -y upgrade && apt-get install -y --no-install-recommends apt-utils \
  && apt-get install -y --no-install-recommends \
  curl locales ca-certificates \
  build-essential sudo gnupg \
  && localedef -i en_US -c -f UTF-8 -A /usr/share/locale/locale.alias en_US 

RUN apt-get clean 

RUN apt-get install -y pkg-config apt-transport-https vim htop build-essential bash-completion git \
  locales lsb-release php7.2-cli php7.2-common php7.2-curl php7.2-fpm php7.2-intl php7.2-soap php7.2-xml php7.2-gd \
  php7.2-readline nginx-light php7.2-mbstring zip unzip nano iputils-ping

# install nodejs
RUN curl -sL https://deb.nodesource.com/setup_11.x  | bash -
RUN apt-get install -y nodejs

# composer and php
RUN curl https://getcomposer.org/composer.phar > /usr/bin/composer && chmod +x /usr/bin/composer && composer self-update
RUN sed -i 's/\/run\/php\/php7.2-fpm.sock/127.0.0.1:9000/g' /etc/php/7.2/fpm/pool.d/www.conf

# append fastcgi_param SCRIPT_FILENAME
RUN echo 'fastcgi_param  SCRIPT_FILENAME    $document_root/$fastcgi_script_name;' >> /etc/nginx/fastcgi_params
RUN service nginx restart

RUN apt-get purge -y build-essential dpkg-dev && apt-get autoremove -y && apt-get clean

COPY ./portal-entrypoint /usr/bin/portal-entrypoint
RUN chmod +x /usr/bin/portal-entrypoint


# ports
EXPOSE 80

# commands
CMD ["/bin/bash", "/usr/bin/portal-entrypoint"]

Upvotes: 0

Views: 2714

Answers (1)

aadlani
aadlani

Reputation: 661

Your problem looks definitely like a network problem. What's strange to me is that your apt installs are going through but you timeout on the 2MB of composer.phar.

I would advise you to go through the steps manually, starting with docker run -it ubuntu:18.04 bash, and execute the RUN commands in the shell so that you can debug your situation.

Another piece of advice for you, before you release your docker image, would be to reduce or group the number of RUN statements in your Dockerfile to reduce the number of layers, and to maybe use a smaller base image. In Docker, the instructions RUN, COPY, ADD create layers, you can check the documentation about the best practices for writing Dockerfiles.

Upvotes: 2

Related Questions