【问题标题】:Docker returned a non-zero code: 28 when install composer安装作曲家时 Docker 返回非零代码:28
【发布时间】:2019-05-10 10:11:57
【问题描述】:

我使用 docker-compose 来处理我的应用程序。但是当我构建 Dokerfile 时,它​​会在 5 分钟后在 curl composer 步骤返回一个非零代码 (28) 作为错误。 我们的办公室通过 VPN 连接到互联网,我们的下载速度限制为最大 120k。

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"]

【问题讨论】:

    标签: docker curl docker-compose composer-php


    【解决方案1】:

    您的问题看起来肯定是网络问题。令我感到奇怪的是,您的 apt 安装正在进行,但您在 composer.phar 的 2MB 上超时。

    我建议您手动完成这些步骤,从 docker run -it ubuntu:18.04 bash 开始,然后在 shell 中执行 RUN 命令,以便调试您的情况。

    在发布 docker 映像之前,给您的另一条建议是减少或分组 Dockerfile 中的 RUN 语句的数量以减少层数,并可能使用更小的基础映像.在 Docker 中,RUNCOPYADD 创建层的指令,你可以查看best practices for writing Dockerfiles 的文档。

    【讨论】:

      猜你喜欢
      • 2016-02-27
      • 2015-08-23
      • 1970-01-01
      • 2016-12-29
      • 1970-01-01
      • 2013-05-26
      • 2021-10-30
      • 1970-01-01
      • 2018-10-09
      相关资源
      最近更新 更多