利用ubuntu18.04设置镜像在有交互状态下安装nginx会要求输入区域等信息,然后打包时就卡住了
查了下以前的资料可以写成这样来进行避免交互操作
RUN export DEBIAN_FRONTEND=noninteractive \
&& apt-get update && apt-get install nginx nginx-extras -y \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
新版本的docker仅需要定义一个arg即可解决问题,完整的Dockerfile如下:
FROM ubuntu:18.04
LABEL maintainer="sunsl@live.com"
ADD sources.list /etc/apt/
ARG DEBIAN_FRONTEND=noninteractive
RUN apt-get update && apt install nginx nginx-extras -y \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
VOLUME [ "/ect/nginx/","/etc/nginx/conf.d1","/data/nginx/logs" ]
EXPOSE 80 443
网友评论