Ubuntu Docker 和 ElasticBeanstalk 的版本更新错误

Ubuntu version update error with Docker and ElasticBeanstalk

我试图理解为什么我无法在给定的 Elastic Beanstalk example 上使用 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"]

日志文件给出:"returned a non-zero code: 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

提示: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/*