Docker和ElasticBeanstalk的Ubuntu版本更新错误

时间:2015-05-23 09:51:41

标签: ubuntu docker elastic-beanstalk

我试图理解为什么我不能使用Docker在给定的Elastic Beanstalk example上升级Ubuntu版本。

这很好用:

FROM ubuntu:12.04

RUN apt-get update
RUN apt-get install -y nginx zip curl

RUN echo "daemon off;" >> /etc/nginx/nginx.conf
RUN curl -o /usr/share/nginx/www/master.zip -L https://codeload.github.com/gabrielecirulli/2048/zip/master
RUN cd /usr/share/nginx/www/ && unzip master.zip && mv 2048-master/* . && rm -rf 2048-master master.zip

EXPOSE 80

CMD ["/usr/sbin/nginx", "-c", "/etc/nginx/nginx.conf"]

这不是:

FROM ubuntu:14.04

RUN apt-get update
RUN apt-get install -y nginx zip curl

RUN echo "daemon off;" >> /etc/nginx/nginx.conf
RUN curl -o /usr/share/nginx/www/master.zip -L https://codeload.github.com/gabrielecirulli/2048/zip/master
RUN cd /usr/share/nginx/www/ && unzip master.zip && mv 2048-master/* . && rm -rf 2048-master master.zip

EXPOSE 80

CMD ["/usr/sbin/nginx", "-c", "/etc/nginx/nginx.conf"]

日志文件给出:“返回非零代码:127”错误。

1 个答案:

答案 0 :(得分:3)

命令失败,因为容器中没有/usr/share/nginx/www目录,但有/usr/share/nginx/html

 ---> 1911c575617e
Step 4 : RUN curl -o /usr/share/nginx/www/master.zip -L https://codeload.github.com/gabrielecirulli/2048/zip/master
 ---> Running in d0ad1a5e7a3f
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0Warning: Failed to create the file /usr/share/nginx/www/master.zip: No such
Warning: file or directory
  0  324k    0   867    0     0   1969      0  0:02:48 --:--:--  0:02:48  1965
curl: (23) Failed writing body (0 != 867)
INFO[0000] The command [/bin/sh -c curl -o /usr/share/nginx/www/master.zip -L https://codeload.github.com/gabrielecirulli/2048/zip/master] returned a non-zero code: 23
$ docker run --rm -ti 1911c575617e
root@bfb101f5de87:/# ls -al  /usr/share/nginx/www
ls: cannot access /usr/share/nginx/www: No such file or directory
root@bfb101f5de87:/# ls -al  /usr/share/nginx
total 12
drwxr-xr-x  3 root root 4096 May 23 11:04 .
drwxr-xr-x 65 root root 4096 May 23 11:04 ..
drwxr-xr-x  2 root root 4096 May 23 11:04 html

提示:Best practice将对apt-get update && apt-get install使用相同的运行命令。也总是尝试在创建时删除相同运行命令中的临时文件:每个运行命令创建附加映像,因此如果您在一个运行命令中获取文件并在下一个中删除 - 它将仅标记为已删除,但它将不必要的增加图像大小在我的大多数图像中,我使用单一运行命令,对于ubuntu / debian看起来像:

RUN echo 'debconf debconf/frontend select Noninteractive' | debconf-set-selections \
 && apt-get update -qq \
 && apt-get install -y -qq ... \
 ...
 && apt-get clean \
 && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*