繁体   English   中英

Docker和ElasticBeanstalk的Ubuntu版本更新错误

[英]Ubuntu version update error with Docker and ElasticBeanstalk

我试图理解为什么我不能在给定的Elastic Beanstalk 示例中使用Docker进行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”。

命令失败,因为容器中没有/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

提示: 最佳实践是对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/*

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM