Phi*_*ßen 217 apt automation docker letsencrypt
我想在带有 Ubuntu 16.04 映像的docker环境中安装certbot:
例如:
docker run -it ubuntu:16.04 /bin/bash
Run Code Online (Sandbox Code Playgroud)
当我在容器内时,安装 certbot 的最直接方法不起作用,因为它需要用户干预:
apt-get update && \
apt-get install -y software-properties-common && \
add-apt-repository -y -u ppa:certbot/certbot && \
apt-get install -y certbot
Run Code Online (Sandbox Code Playgroud)
问题是tzdata,这个交互式对话框停止了:
Extracting templates from packages: 100%
Preconfiguring packages ...
Configuring tzdata
------------------
Please select the geographic area in which you live. Subsequent configuration
questions will narrow this down by presenting a list of cities, representing
the time zones in which they are located.
1. Africa 4. Australia 7. Atlantic 10. Pacific 13. Etc
2. America 5. Arctic 8. Europe 11. SystemV
3. Antarctica 6. Asia 9. Indian 12. US
Geographic area:
Run Code Online (Sandbox Code Playgroud)
奇怪的是,当我tzdata在添加 ppa 之前安装时它可以工作:
apt-get update && \
apt-get install -y tzdata && \
apt-get install -y software-properties-common && \
add-apt-repository -y -u ppa:certbot/certbot && \
apt-get install -y certbot
Run Code Online (Sandbox Code Playgroud)
问题:
tzdata在添加 ppa 之前或之后安装会有所不同?小智 249
要在dpkg没有交互式对话的情况下运行(在 Apt 等其他工具后面),您可以将一个环境变量设置为
DEBIAN_FRONTEND=noninteractive
Run Code Online (Sandbox Code Playgroud)
例如,您可以使用ARG在 Dockerfile 中设置它:
ARG DEBIAN_FRONTEND=noninteractive
Run Code Online (Sandbox Code Playgroud)
Ter*_*sim 73
在 Ubuntu 18.04 上,我做了那个 Dockerfile:
ENV TZ=Europe/Minsk
RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone
RUN apt update && apt instal....
Run Code Online (Sandbox Code Playgroud)
小智 57
TL&DR: 在你的 DockerFile 中
ENV DEBIAN_FRONTEND=noninteractive
Run Code Online (Sandbox Code Playgroud)
原因:
某些安装程序通过拥有漂亮的前端使“安装”更容易。虽然这在您手动安装时很好,但在自动安装期间这会成为一个问题。
您可以通过在您的环境字符串中放置以下内容来覆盖交互式安装。
干杯
小智 23
您可以DEBIAN_FRONTEND=noninteractive在命令之前设置以避免ENV DEBIAN_FRONTEND=noninteractive影响命令之后或子图像:
RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \
tzdata \
&& rm -rf /var/lib/apt/lists/*
Run Code Online (Sandbox Code Playgroud)
您应该在安装之前设置您的时区tzdata:
# Set timezone:
RUN ln -snf /usr/share/zoneinfo/$CONTAINER_TIMEZONE /etc/localtime && echo $CONTAINER_TIMEZONE > /etc/timezone
# Install dependencies:
RUN apt-get update && apt-get install -y tzdata
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
115934 次 |
| 最近记录: |