我尝试过很多方法,包括
ENV DEBIAN_FRONTEND=noninteractive
ENV TZ=Europe/Lnndon
RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone
但无论我做什么我都会得到
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:
并且用户输入不起作用(我真的希望它是非交互式的)。
这是完整的 Dockerfile。
FROM ubuntu:18.04
ENV DEBIAN_FRONTEND=noninteractive
ENV TZ=Europe/Lnndon
RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone
#install all the system dependencies and enable PHP modules
RUN apt-get update && apt-get install -yq --no-install-recommends \
apt-utils \
curl \
# Install git
git \
# Install apache
apache2 \
# Install php 7.2
libapache2-mod-php7.2 \
php7.2-cli \
php7.2-json \
php7.2-curl \
php7.2-fpm \
php7.2-gd \
php7.2-ldap \
php7.2-mbstring \
php7.2-mysql \
php7.2-soap \
php7.2-sqlite3 \
php7.2-xml \
php7.2-zip \
php7.2-intl \
php-imagick \
# Install tools
openssl \
nano \
graphicsmagick \
imagemagick \
ghostscript \
mysql-client \
iputils-ping \
locales \
sqlite3 \
ca-certificates \
&& apt-get clean && rm -rf /var/lib/apt/lists/*
# Install composer
RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer
#set our application folder as an environment variable
ENV APP_HOME /var/www/html
#change uid and gid of apache to docker user uid/gid
RUN usermod -u 1000 www-data && groupmod -g 1000 www-data
#change the web_root to laravel /var/www/html/public folder
RUN sed -i -e "s/html/html\/public/g" /etc/apache2/sites-enabled/000-default.conf
# enable apache module rewrite
RUN a2enmod rewrite
#copy source files and run composer
COPY . $APP_HOME
# install all PHP dependencies
RUN composer install --no-interaction
#change ownership of our applications
RUN chown -R www-data:www-data $APP_HOME
知道如何修复这个问题吗?
答案1
这对我有用。这是 Dockerfile:
FROM ubuntu:20.04
RUN apt update && DEBIAN_FRONTEND=noninteractive apt install -y --no-install-recommends git cmake g++
# Cleanup
RUN apt-get clean && \
rm -rf /var/lib/apt
软件包git
、cmake
和g++
是我在图片中需要的。将其替换为您需要的软件包。
答案2
我建议不要将时区设置为固定的,而是从环境变量中传递它。
Dockerfile:
FROM ubuntu
RUN apt-get update && apt-get upgrade -y \
&& apt-get install -y tzdata
命令行:
docker run -it -e TZ=America/New_York <IMAGE> date