स्थापित करने के लिए कैसे tzdata पर एक ubuntu डोकर छवि?

मेरे पास डॉकरफाइल में निम्न पंक्ति है ।

RUN apt-get install -y tzdata

जब मैं इसे चलाता हूं, तो यह मेरा इनपुट मांगता है । मैंने अपना इनपुट प्रदान करने के बाद, यह वहां लटका दिया । क्या कोई इस समस्या को हल करना जानता है?

Step 25/25 : RUN apt-get install -y tzdata ---> Running in ee47a1beff84Reading package lists...Building dependency tree...Reading state information...The following NEW packages will be installed:  tzdata0 upgraded, 1 newly installed, 0 to remove and 0 not upgraded.Need to get 189 kB of archives.After this operation, 3104 kB of additional disk space will be used.Get:1 http://archive.ubuntu.com/ubuntu bionic-updates/main amd64 tzdata all 2018i-0ubuntu0.18.04 [189 kB]debconf: unable to initialize frontend: Dialogdebconf: (TERM is not set, so the dialog frontend is not usable.)debconf: falling back to frontend: Readlinedebconf: unable to initialize frontend: Readlinedebconf: (This frontend requires a controlling tty.)debconf: falling back to frontend: Teletypedpkg-preconfigure: unable to re-open stdin: Fetched 189 kB in 1s (219 kB/s)Selecting previously unselected package tzdata.(Reading database ... 25194 files and directories currently installed.)Preparing to unpack .../tzdata_2018i-0ubuntu0.18.04_all.deb ...Unpacking tzdata (2018i-0ubuntu0.18.04) ...Setting up tzdata (2018i-0ubuntu0.18.04) ...debconf: unable to initialize frontend: Dialogdebconf: (TERM is not set, so the dialog frontend is not usable.)debconf: falling back to frontend: ReadlineConfiguring tzdata------------------Please select the geographic area in which you live. Subsequent configurationquestions will narrow this down by presenting a list of cities, representingthe 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. USGeographic area:``

केवल एक पंक्ति:

RUN DEBIAN_FRONTEND=noninteractive TZ=Etc/UTC apt-get -y install tzdata

आप उपयोग कर सकते हैं ARG और ENV आपके लाभ के लिए निर्देश:

ARG DEBIAN_FRONTEND=noninteractiveENV TZ=Europe/MoscowRUN apt-get install -y tzdata

इस तरह DEBIAN_FRONTEND जब आप अपनी छवि बनाते हैं तो केवल परिभाषित किया जाएगा TZ रनटाइम पर बनी रहेगी।

आपको कमांड की सीरी निष्पादित करने की आवश्यकता है:

    # set noninteractive installation    export DEBIAN_FRONTEND=noninteractive    # install tzdata package    apt-get install -y tzdata    # set your timezone    ln -fs /usr/share/zoneinfo/America/New_York /etc/localtime    dpkg-reconfigure --frontend noninteractive tzdata

(कमांड जो शुरू होते हैं # टिप्पणियां हैं और आप उन्हें अनदेखा कर सकते हैं)

स्क्रिप्ट बनाने का सबसे अच्छा तरीका है, स्क्रिप्ट को कंटेनर में कॉपी करें और इसे डॉकरफाइल में निष्पादित करें:

ADD yourscript.sh /yourscript.shRUN /yourscript.sh

डॉकर-कंपोज़ फ़ाइल में दो पर्यावरण चर सेट करें । एक प्रॉम्प्ट को अक्षम करता है, और दूसरा टाइमज़ोन सेट करता है ।

डॉकर-लिखें।yml

version: '3.7'services:  timezone:    build: .    environment:      - TZ=America/New_York      - DEBIAN_FRONTEND=noninteractive

फिर बस स्थापित करें tzdata आपकी छवि में ।

Dockerfile

FROM ubuntu:18.04RUN apt-get update && apt-get install -y tzdata# Testing command: Print the date.  It will be in the timezone set from the compose file.CMD date

परीक्षण करने के लिए:

docker-compose build timezone

सुनिश्चित करें कि आप @पीटरटीसी के समाधान का उपयोग कर रहे हैं और कर रहे हैं apt-get update && apt-get install उसी लाइन पर कि DEBIAN_FRONTEND कथन है के बाद&&:

सही:

RUN apt-get update && DEBIAN_FRONTEND="noninteractive" TZ="America/New_York" apt-get install -y tzdata

गलत:

RUN DEBIAN_FRONTEND="noninteractive" TZ="America/New_York" apt-get update && apt-get install -y tzdata

एक साधारण डॉकरफाइल से यह काम करता है लेकिन इसे और अधिक ट्विकिंग की आवश्यकता हो सकती है (टीजेड 1 9:25 है लेकिन डॉकर के अंदर 16:25, आईडीसी अब क्योंकि यह एआरएम 64 जेटसन नैनो पर स्वचालन उद्देश्य के लिए है)

RUN export TZ=Europe/ParisRUN pip3 install -U Cython contextlib2 pillow lxml jupyter matplotlibRUN DEBIAN_FRONTEND=noninteractive apt-get install protobuf-compiler python-pil python-lxml python-tk -y
Unpacking protobuf-compiler (3.0.0-9.1ubuntu1) ...Setting up python-chardet (3.0.4-1) ...Setting up tzdata (2019c-0ubuntu0.18.04) ...Current default time zone: 'Etc/UTC'Local time is now:      Wed Apr 22 16:25:17 UTC 2020.Universal Time is now:  Wed Apr 22 16:25:17 UTC 2020.Run 'dpkg-reconfigure tzdata' if you wish to change it.Setting up libxss1:arm64 (1:1.2.2-1) ...

मेरे लिए, यह काम किया और मैंने इस तरह से पसंद किया (इस तरह आपको एक गैर-सक्रिय मोड सेट करने की आवश्यकता नहीं है):

उदाहरण के लिए, अपने टाइमज़ोन के साथ एक पर्यावरण चर सेट करें:ENV TZ=Europe/Madrid

फिर, इस चर को एक फ़ाइल में प्रिंट करें और फिर उस फ़ाइल को उस फ़ाइल से लिंक करें जिसे कॉन्फ़िगरेशन प्रक्रिया तजडाटा स्थापित करते समय पढ़ेगी:RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone

अंत में, सामान्य रूप से टज़डाटा स्थापित करें: RUN apt-get update && apt-get install -y tzdata

से निकाला गया: https://dev.to/setevoy/docker-configure-tzdata-and-timezone-during-build-20bk

फोकल 20.04 पर समाधान का उपयोग कर TZ=... और DEBIAN_FRONTEND=... अब काम नहीं करता । यह बायोनिक 18.04 तक काम करता था । डॉकर फ़ाइल स्निपेट जो फोकल लुक के लिए काम करता है:

   ## preesed tzdata, update package index, upgrade packages and install needed software   RUN truncate -s0 /tmp/preseed.cfg && \       (echo "tzdata tzdata/Areas select America" >> /tmp/preseed.cfg) && \       (echo "tzdata tzdata/Zones/America select Los_Angeles" >> /tmp/preseed.cfg) && \       debconf-set-selections /tmp/preseed.cfg && \       rm -f /etc/timezone /etc/localtime && \       apt-get update && \       DEBIAN_FRONTEND=noninteractive DEBCONF_NONINTERACTIVE_SEEN=true \       apt-get install -y tzdata   ## cleanup of files from setup   RUN rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*

समाधान ज्यादातर से लिया गया है दूसरे stackoverflow विषय.

उबंटू 22: 04 छवि पर, मुझे मिला:

Setting up locales (2.34-0ubuntu3) ...debconf: unable to initialize frontend: Dialogdebconf: (TERM is not set, so the dialog frontend is not usable.)debconf: falling back to frontend: ReadlineGenerating locales (this might take a while)...  de_AT.UTF-8... done  ...  sv_SE.UTF-8... doneGeneration complete.Setting up libjansson4:amd64 (2.13.1-1.1build2) ...Setting up libsasl2-modules-db:amd64 (2.1.27+dfsg2-2build1) ...Setting up tzdata (2021e-1ubuntu1) ...debconf: unable to initialize frontend: Dialogdebconf: (TERM is not set, so the dialog frontend is not usable.)debconf: falling back to frontend: ReadlineConfiguring tzdata------------------Please select the geographic area in which you live. Subsequent configurationquestions will narrow this down by presenting a list of cities, representingthe time zones in which they are located.  1. Africa   3. Antarctica  5. Arctic  7. Atlantic  9. Indian    11. US  2. America  4. Australia   6. Asia    8. Europe    10. Pacific  12. EtcGeographic area:

ताकि डोकलाम का निर्माण न हो ।

से लिया गया जब तक टर्म लिनक्स #58 पर सेट न हो जाए, तब तक ढेर सारे डिबकॉन्फ़ संदेश प्राप्त करना, मुझे दौड़ने की जरूरत थी:

RUN echo 'debconf debconf/frontend select Noninteractive' | debconf-set-selections# And afterwards whatever you like, for example:RUN DEBIAN_FRONTEND=noninteractive apt-get update && apt-get -y \--no-install-recommends install ...

जिसने लापता टर्मिनल पर डेबकॉन्फ़ रिपोर्टिंग को रोक दिया और डॉकरफ़ाइल बिल्ड के दौरान स्थान मेनू खोलने से टज़डाटा इंस्टॉलर को भी रोक दिया ।