无法在 Ubuntu 20.04 docker 镜像上安装 software-properties-common

无法在 Ubuntu 20.04 docker 镜像上安装 software-properties-common

尝试使用 Dockerfile 执行 docker 构建,以在基于 Ubuntu 20.04 的 hashicorp/tfc-agent:latest docker 镜像上安装 software-properties-common 包。

当我尝试运行时docker build,收到以下错误消息。

我尝试过apt-get install -fapt-get install --fix-brokenapt-get --reinstall install systemd.timesyncd。但这些都没有用。

如果有人遇到过这个问题,请分享一下解决方法,我将不胜感激。谢谢。

14.27 Get:74 http://archive.ubuntu.com/ubuntu focal/main amd64 python3-certifi all 2019.11.28-1 [149 kB]
14.30 Get:75 http://archive.ubuntu.com/ubuntu focal/main amd64 python3-chardet all 3.0.4-4build1 [80.4 kB]
14.30 Get:76 http://archive.ubuntu.com/ubuntu focal/main amd64 python3-idna all 2.8-1 [34.6 kB]
14.31 Get:77 http://archive.ubuntu.com/ubuntu focal-updates/main amd64 python3-urllib3 all 1.25.8-2ubuntu0.2 [88.4 kB]
14.65 Get:78 http://archive.ubuntu.com/ubuntu focal-updates/main amd64 python3-requests all 2.22.0-2ubuntu1.1 [47.2 kB]
15.18 Get:79 http://archive.ubuntu.com/ubuntu focal/main amd64 python3-requests-unixsocket all 0.2.0-2 [7272 B]
15.19 Get:80 http://archive.ubuntu.com/ubuntu focal-updates/main amd64 python3-software-properties all 0.99.9.11 [21.6 kB]
15.23 Get:81 http://archive.ubuntu.com/ubuntu focal-updates/main amd64 software-properties-common all 0.99.9.11 [10.4 kB]
15.25 Get:82 http://archive.ubuntu.com/ubuntu focal-updates/main amd64 unattended-upgrades all 2.3ubuntu0.3 [48.5 kB]
15.70 debconf: delaying package configuration, since apt-utils is not installed
15.77 Fetched 25.2 MB in 14s (1808 kB/s)
15.86 Selecting previously unselected package libapparmor1:amd64.
(Reading database ... 10650 files and directories currently installed.)
15.87 Preparing to unpack .../0-libapparmor1_2.13.3-7ubuntu5.2_amd64.deb ...
15.88 Unpacking libapparmor1:amd64 (2.13.3-7ubuntu5.2) ...
15.97 Selecting previously unselected package libargon2-1:amd64.
15.97 Preparing to unpack .../1-libargon2-1_0~20171227-0.2_amd64.deb ...
15.97 Unpacking libargon2-1:amd64 (0~20171227-0.2) ...
16.06 Selecting previously unselected package libdevmapper1.02.1:amd64.
16.06 Preparing to unpack .../2-libdevmapper1.02.1_2%3a1.02.167-1ubuntu1_amd64.deb ...
16.06 Unpacking libdevmapper1.02.1:amd64 (2:1.02.167-1ubuntu1) ...
16.15 Selecting previously unselected package libjson-c4:amd64.
16.15 Preparing to unpack .../3-libjson-c4_0.13.1+dfsg-7ubuntu0.3_amd64.deb ...
16.15 Unpacking libjson-c4:amd64 (0.13.1+dfsg-7ubuntu0.3) ...
16.24 Selecting previously unselected package libcryptsetup12:amd64.
16.24 Preparing to unpack .../4-libcryptsetup12_2%3a2.2.2-3ubuntu2.4_amd64.deb ...
16.24 Unpacking libcryptsetup12:amd64 (2:2.2.2-3ubuntu2.4) ...
16.34 Selecting previously unselected package libip4tc2:amd64.
16.34 Preparing to unpack .../5-libip4tc2_1.8.4-3ubuntu2.1_amd64.deb ...
16.34 Unpacking libip4tc2:amd64 (1.8.4-3ubuntu2.1) ...
16.43 Selecting previously unselected package libkmod2:amd64.
16.43 Preparing to unpack .../6-libkmod2_27-1ubuntu2.1_amd64.deb ...
16.43 Unpacking libkmod2:amd64 (27-1ubuntu2.1) ...
16.52 Selecting previously unselected package systemd-timesyncd.
16.52 Preparing to unpack .../7-systemd-timesyncd_245.4-4ubuntu3.22_amd64.deb ...
16.52 Unpacking systemd-timesyncd (245.4-4ubuntu3.22) ...
16.61 Selecting previously unselected package systemd.
16.61 Preparing to unpack .../8-systemd_245.4-4ubuntu3.22_amd64.deb ...
17.07 Unpacking systemd (245.4-4ubuntu3.22) ...
17.45 Setting up libapparmor1:amd64 (2.13.3-7ubuntu5.2) ...
17.46 Setting up libargon2-1:amd64 (0~20171227-0.2) ...
17.46 Setting up libdevmapper1.02.1:amd64 (2:1.02.167-1ubuntu1) ...
17.46 Setting up libjson-c4:amd64 (0.13.1+dfsg-7ubuntu0.3) ...
17.47 Setting up libcryptsetup12:amd64 (2:2.2.2-3ubuntu2.4) ...
17.47 Setting up libip4tc2:amd64 (1.8.4-3ubuntu2.1) ...
17.48 Setting up libkmod2:amd64 (27-1ubuntu2.1) ...
17.48 Setting up systemd-timesyncd (245.4-4ubuntu3.22) ...
17.72 adduser: Could not find program named `chage' in $PATH.
17.73 dpkg: error processing package systemd-timesyncd (--configure):
17.73  installed systemd-timesyncd package post-installation script subprocess returned error exit status 1
17.73 dpkg: dependency problems prevent configuration of systemd:
17.73  systemd depends on systemd-timesyncd | time-daemon; however:
17.73   Package systemd-timesyncd is not configured yet.
17.73   Package time-daemon is not installed.
17.73   Package systemd-timesyncd which provides time-daemon is not configured yet.
17.73
17.73 dpkg: error processing package systemd (--configure):
17.73  dependency problems - leaving unconfigured
17.73 Errors were encountered while processing:
17.73  systemd-timesyncd
17.73  systemd
17.77 E: Sub-process /usr/bin/dpkg returned an error code (1)
------
Dockerfile:31
--------------------
  29 |     # RUN apt install -y chrony
  30 |
  31 | >>> RUN apt-get install -y software-properties-common
  32 |
  33 |     # #RUN apt-get install -y --no-install-recommends apt-utils passwd
--------------------
ERROR: failed to solve: process "/bin/sh -c apt-get install -y software-properties-common" did not complete successfully: exit code: 100

答案1

这是我唯一能做到的事情:

    RUN apt install -y -f software-properties-common || sudo dpkg --configure -a && apt install -y -f software-properties-common|| sudo dpkg --configure -a && apt install -y -f software-properties-common || sudo dpkg --configure -a && apt install -y -f software-properties-common || sudo dpkg --configure -a && apt install -y -f software-properties-common

运行 dpkg --configure -a 后,它可以配置导致问题的另一个内容,并且需要总共运行 5 次才能修复所有损坏的配置。

我知道这很肮脏,但找不到更好的解决办法

相关内容