openjdk docker base上.deb文件的Java依赖项失败

2020年5月5日 12点热度 0条评论

我一直在从事一个开源项目。它使用在jdk8镜像上安装的生成生成的debian(.deb)软件包创建docker镜像。

但是最近我开始出现错误,不幸的是我无法克服它。通过Dockerfile启动dpkg命令后。它说找不到对jdk / jre的依赖关系。这很有趣,因为该库是openjdk / jdk8

====== Dockerfile ======

FROM openjdk:8-jdk

COPY *.deb /tmp/
RUN chmod +x /tmp/application.deb
RUN java -version

RUN ls -lrth /tmp/
RUN dpkg -I /tmp/application.deb
RUN dpkg -i /tmp/application.deb

======启动docker命令======

docker build --no-cache -t jdk8-img .

====== docker build输出======

Sending build context to Docker daemon  103.3MB
Step 1/7 : FROM openjdk:8-jdk
 ---> d318d6aeb831
Step 2/7 : COPY *.deb /tmp/
 ---> 74305ee50ee7
Step 3/7 : RUN chmod +x /tmp/application.deb
 ---> Running in de51d99b4570
Removing intermediate container de51d99b4570
 ---> cb47ff56ec1c
Step 4/7 : RUN java -version
 ---> Running in a14700fcc037
openjdk version "1.8.0_212"
OpenJDK Runtime Environment (build 1.8.0_212-b04)
OpenJDK 64-Bit Server VM (build 25.212-b04, mixed mode)
Removing intermediate container a14700fcc037
 ---> 813cc1108cc7
Step 5/7 : RUN ls -lrth /tmp/
 ---> Running in 0255efbfd08c
total 99M
-rwxr-xr-x 1 root root  99M May 28 12:23 application.deb
drwxr-xr-x 1 root root 4.0K May 28 12:25 hsperfdata_root
Removing intermediate container 0255efbfd08c
 ---> ebd1965f1b97
Step 6/7 : RUN dpkg -I /tmp/application.deb
 ---> Running in 7f7411200dbd
 new debian package, version 2.0.
 size 103337854 bytes: control archive=2382 bytes.
     175 bytes,     4 lines      conffiles            
     266 bytes,    10 lines      control              
    4549 bytes,    48 lines      md5sums              
     255 bytes,    21 lines   *  postinst             #!/bin/sh
      52 bytes,     7 lines   *  postrm               #!/bin/sh
     534 bytes,    26 lines   *  preinst              #!/bin/sh
     103 bytes,     9 lines   *  prerm                #!/bin/sh
 Package: application
 Source: application
 Version: 2.3.1-1
 Section: java
 Priority: optional
 Architecture: all
 Depends: openjdk-8-jre | java8-runtime | oracle-java8-installer | openjdk-8-jre-headless
 Installed-Size: 112298
 Maintainer: eolgkay
 Description: application
Removing intermediate container 7f7411200dbd
 ---> 1f9db460cbdd
Step 7/7 : RUN dpkg -i /tmp/application.deb
 ---> Running in bba045241db9
Selecting previously unselected package application.
(Reading database ... 12354 files and directories currently installed.)
Preparing to unpack /tmp/application.deb ...
Adding group `application' (GID 102) ...
Done.
Unpacking application (2.3.1-1) ...
dpkg: dependency problems prevent configuration of application:
 application depends on openjdk-8-jre | java8-runtime | oracle-java8-installer | openjdk-8-jre-headless; however:
  Package openjdk-8-jre is not installed.
  Package java8-runtime is not installed.
  Package oracle-java8-installer is not installed.
  Package openjdk-8-jre-headless is not installed.

dpkg: error processing package application (--install):
 dependency problems - leaving unconfigured
Errors were encountered while processing:
 application
The command '/bin/sh -c dpkg -i /tmp/application.deb' returned a non-zero code: 1

如您所见,这太奇怪了;我只是检查了环境(即使我知道基准是openjdk:jdk8),也将其全部打印到输出中。

更新

我一直在调试该问题,似乎dpkg已安装的应用程序列表不包含与Java相关的软件包。

Step 6/6 : RUN dpkg -l
 ---> Running in ac30028e4fb9
Desired=Unknown/Install/Remove/Purge/Hold
| Status=Not/Inst/Conf-files/Unpacked/halF-conf/Half-inst/trig-aWait/Trig-pend
|/ Err?=(none)/Reinst-required (Status,Err: uppercase=bad)
||/ Name                       Version                        Architecture Description
+++-==========================-==============================-============-===============================================================================
ii  adduser                    3.115                          all          add and remove users and groups
ii  apt                        1.4.9                          amd64        commandline package manager
ii  base-files                 9.9+deb9u9                     amd64        Debian base system miscellaneous files
ii  base-passwd                3.5.43                         amd64        Debian base system master password and group files
ii  bash                       4.4-5                          amd64        GNU Bourne Again SHell
ii  bsdutils                   1:2.29.2-1+deb9u1              amd64        basic utilities from 4.4BSD-Lite
ii  bzip2                      1.0.6-8.1                      amd64        high-quality block-sorting file compressor - utilities
ii  bzr                        2.7.0+bzr6619-7+deb9u1         all          easy to use distributed version control system
ii  ca-certificates            20161130+nmu1+deb9u1           all          Common CA certificates
ii  coreutils                  8.26-3                         amd64        GNU core utilities
ii  curl                       7.52.1-5+deb9u9                amd64        command line tool for transferring data with URL syntax
ii  dash                       0.5.8-2.4                      amd64        POSIX-compliant shell
ii  debconf                    1.5.61                         all          Debian configuration management system
ii  debian-archive-keyring     2017.5                         all          GnuPG archive keys of the Debian archive
ii  debianutils                4.8.1.1                        amd64        Miscellaneous utilities specific to Debian
ii  diffutils                  1:3.5-3                        amd64        File comparison utilities
ii  dirmngr                    2.1.18-8~deb9u4                amd64        GNU privacy guard - network certificate management service
ii  dpkg                       1.18.25                        amd64        Debian package management system
ii  e2fslibs:amd64             1.43.4-2                       amd64        ext2/ext3/ext4 file system libraries
ii  e2fsprogs                  1.43.4-2                       amd64        ext2/ext3/ext4 file system utilities
ii  findutils                  4.6.0+git+20161106-2           amd64        utilities for finding files--find, xargs
ii  fontconfig                 2.11.0-6.7+b1                  amd64        generic font configuration library - support binaries
ii  fontconfig-config          2.11.0-6.7                     all          generic font configuration library - configuration
ii  fonts-dejavu-core          2.37-1                         all          Vera font family derivate with additional characters
ii  gcc-6-base:amd64           6.3.0-18+deb9u1                amd64        GCC, the GNU Compiler Collection (base package)
ii  git                        1:2.11.0-3+deb9u4              amd64        fast, scalable, distributed revision control system
ii  git-man                    1:2.11.0-3+deb9u4              all          fast, scalable, distributed revision control system (manual pages)
ii  gnupg                      2.1.18-8~deb9u4                amd64        GNU privacy guard - a free PGP replacement
ii  gnupg-agent                2.1.18-8~deb9u4                amd64        GNU privacy guard - cryptographic agent
ii  gpgv                       2.1.18-8~deb9u4                amd64        GNU privacy guard - signature verification tool
ii  grep                       2.27-2                         amd64        GNU grep, egrep and fgrep
ii  gzip                       1.6-5+b1                       amd64        GNU compression utilities
ii  hostname                   3.18+b1                        amd64        utility to set/show the host name or domain name
ii  init-system-helpers        1.48                           all          helper tools for all init systems
ii  iproute2                   4.9.0-1+deb9u1                 amd64        networking and traffic control tools
ii  iputils-ping               3:20161105-1                   amd64        Tools to test the reachability of network hosts
ii  libacl1:amd64              2.2.52-3+b1                    amd64        Access control list shared library
ii  libapr1:amd64              1.5.2-5                        amd64        Apache Portable Runtime Library
ii  libaprutil1:amd64          1.5.4-3                        amd64        Apache Portable Runtime Utility Library
ii  libapt-pkg5.0:amd64        1.4.9                          amd64        package management runtime library
ii  libassuan0:amd64           2.4.3-2                        amd64        IPC library for the GnuPG components
ii  libattr1:amd64             1:2.4.47-2+b2                  amd64        Extended attribute shared library
ii  libaudit-common            1:2.6.7-2                      all          Dynamic library for security auditing - common files
ii  libaudit1:amd64            1:2.6.7-2                      amd64        Dynamic library for security auditing
ii  libblkid1:amd64            2.29.2-1+deb9u1                amd64        block device ID library
ii  libbsd0:amd64              0.8.3-1                        amd64        utility functions from BSD systems - shared library
ii  libbz2-1.0:amd64           1.0.6-8.1                      amd64        high-quality block-sorting file compressor library - runtime
ii  libc-bin                   2.24-11+deb9u4                 amd64        GNU C Library: Binaries
ii  libc6:amd64                2.24-11+deb9u4                 amd64        GNU C Library: Shared libraries
ii  libcap-ng0:amd64           0.7.7-3+b1                     amd64        An alternate POSIX capabilities library
ii  libcap2:amd64              1:2.25-1                       amd64        POSIX 1003.1e capabilities (library)
ii  libcomerr2:amd64           1.43.4-2                       amd64        common error description library
ii  libcurl3:amd64             7.52.1-5+deb9u9                amd64        easy-to-use client-side URL transfer library (OpenSSL flavour)
ii  libcurl3-gnutls:amd64      7.52.1-5+deb9u9                amd64        easy-to-use client-side URL transfer library (GnuTLS flavour)
ii  libdb5.3:amd64             5.3.28-12+deb9u1               amd64        Berkeley v5.3 Database Libraries [runtime]
ii  libdebconfclient0:amd64    0.227                          amd64        Debian Configuration Management System (C-implementation library)
ii  libedit2:amd64             3.1-20160903-3                 amd64        BSD editline and history libraries
ii  libelf1:amd64              0.168-1                        amd64        library to read and write ELF files
ii  liberror-perl              0.17024-1                      all          Perl module for error/exception handling in an OO-ish way
ii  libexpat1:amd64            2.2.0-2+deb9u1                 amd64        XML parsing C library - runtime library
ii  libfdisk1:amd64            2.29.2-1+deb9u1                amd64        fdisk partitioning library
ii  libffi6:amd64              3.2.1-6                        amd64        Foreign Function Interface library runtime
ii  libfontconfig1:amd64       2.11.0-6.7+b1                  amd64        generic font configuration library - runtime
ii  libfreetype6:amd64         2.6.3-3.2                      amd64        FreeType 2 font engine, shared library files
ii  libgcc1:amd64              1:6.3.0-18+deb9u1              amd64        GCC support library
ii  libgcrypt20:amd64          1.7.6-2+deb9u3                 amd64        LGPL Crypto library - runtime library
ii  libgdbm3:amd64             1.8.3-14                       amd64        GNU dbm database routines (runtime version)
ii  libgmp10:amd64             2:6.1.2+dfsg-1                 amd64        Multiprecision arithmetic library
ii  libgnutls30:amd64          3.5.8-5+deb9u4                 amd64        GNU TLS library - main runtime library
ii  libgpg-error0:amd64        1.26-2                         amd64        library for common error values and messages in GnuPG components
ii  libgssapi-krb5-2:amd64     1.15-1+deb9u1                  amd64        MIT Kerberos runtime libraries - krb5 GSS-API Mechanism
ii  libhogweed4:amd64          3.3-1+b2                       amd64        low level cryptographic library (public-key cryptos)
ii  libidn11:amd64             1.33-1                         amd64        GNU Libidn library, implementation of IETF IDN specifications
ii  libidn2-0:amd64            0.16-1+deb9u1                  amd64        Internationalized domain names (IDNA2008) library
ii  libjs-excanvas             0.r3-4                         all          HTML5 Canvas for Internet Explorer
ii  libk5crypto3:amd64         1.15-1+deb9u1                  amd64        MIT Kerberos runtime libraries - Crypto Library
ii  libkeyutils1:amd64         1.5.9-9                        amd64        Linux Key Management Utilities (library)
ii  libkrb5-3:amd64            1.15-1+deb9u1                  amd64        MIT Kerberos runtime libraries
ii  libkrb5support0:amd64      1.15-1+deb9u1                  amd64        MIT Kerberos runtime libraries - Support library
ii  libksba8:amd64             1.3.5-2                        amd64        X.509 and CMS support library
ii  libldap-2.4-2:amd64        2.4.44+dfsg-5+deb9u2           amd64        OpenLDAP libraries
ii  libldap-common             2.4.44+dfsg-5+deb9u2           all          OpenLDAP common files for libraries
ii  liblz4-1:amd64             0.0~r131-2+b1                  amd64        Fast LZ compression algorithm library - runtime
ii  liblzma5:amd64             5.2.2-1.2+b1                   amd64        XZ-format compression library
ii  libmnl0:amd64              1.0.4-2                        amd64        minimalistic Netlink communication library
ii  libmount1:amd64            2.29.2-1+deb9u1                amd64        device mounting library
ii  libncurses5:amd64          6.0+20161126-1+deb9u2          amd64        shared libraries for terminal handling
ii  libncursesw5:amd64         6.0+20161126-1+deb9u2          amd64        shared libraries for terminal handling (wide character support)
ii  libnettle6:amd64           3.3-1+b2                       amd64        low level cryptographic library (symmetric and one-way cryptos)
ii  libnghttp2-14:amd64        1.18.1-1                       amd64        library implementing HTTP/2 protocol (shared library)
ii  libnpth0:amd64             1.3-1                          amd64        replacement for GNU Pth using system threads
ii  libp11-kit0:amd64          0.23.3-2                       amd64        library for loading and coordinating access to PKCS#11 modules - runtime
ii  libpam-modules:amd64       1.1.8-3.6                      amd64        Pluggable Authentication Modules for PAM
ii  libpam-modules-bin         1.1.8-3.6                      amd64        Pluggable Authentication Modules for PAM - helper binaries
ii  libpam-runtime             1.1.8-3.6                      all          Runtime support for the PAM library
ii  libpam0g:amd64             1.1.8-3.6                      amd64        Pluggable Authentication Modules library
ii  libpcre3:amd64             2:8.39-3                       amd64        Old Perl 5 Compatible Regular Expression Library - runtime files
ii  libperl5.24:amd64          5.24.1-3+deb9u5                amd64        shared Perl library
ii  libpng16-16:amd64          1.6.28-1+deb9u1                amd64        PNG library - runtime (version 1.6)
ii  libprocps6:amd64           2:3.3.12-3+deb9u1              amd64        library for accessing process information from /proc
ii  libpsl5:amd64              0.17.0-3                       amd64        Library for Public Suffix List (shared libraries)
ii  libpython-stdlib:amd64     2.7.13-2                       amd64        interactive high-level object-oriented language (default python version)
ii  libpython2.7-minimal:amd64 2.7.13-2+deb9u3                amd64        Minimal subset of the Python language (version 2.7)
ii  libpython2.7-stdlib:amd64  2.7.13-2+deb9u3                amd64        Interactive high-level object-oriented language (standard library, version 2.7)
ii  libreadline7:amd64         7.0-3                          amd64        GNU readline and history libraries, run-time libraries
ii  librtmp1:amd64             2.4+20151223.gitfa8646d.1-1+b1 amd64        toolkit for RTMP streams (shared library)
ii  libsasl2-2:amd64           2.1.27~101-g0780600+dfsg-3     amd64        Cyrus SASL - authentication abstraction library
ii  libsasl2-modules-db:amd64  2.1.27~101-g0780600+dfsg-3     amd64        Cyrus SASL - pluggable authentication modules (DB)
ii  libselinux1:amd64          2.6-3+b3                       amd64        SELinux runtime shared libraries
ii  libsemanage-common         2.6-2                          all          Common files for SELinux policy management libraries
ii  libsemanage1:amd64         2.6-2                          amd64        SELinux policy management library
ii  libsepol1:amd64            2.6-2                          amd64        SELinux library for manipulating binary security policies
ii  libserf-1-1:amd64          1.3.9-3+deb9u1                 amd64        high-performance asynchronous HTTP client library
ii  libsmartcols1:amd64        2.29.2-1+deb9u1                amd64        smart column output alignment library
ii  libsqlite3-0:amd64         3.16.2-5+deb9u1                amd64        SQLite 3 shared library
ii  libss2:amd64               1.43.4-2                       amd64        command-line interface parsing library
ii  libssh2-1:amd64            1.7.0-1+deb9u1                 amd64        SSH2 client-side library
ii  libssl1.0.2:amd64          1.0.2r-1~deb9u1                amd64        Secure Sockets Layer toolkit - shared libraries
ii  libssl1.1:amd64            1.1.0j-1~deb9u1                amd64        Secure Sockets Layer toolkit - shared libraries
ii  libstdc++6:amd64           6.3.0-18+deb9u1                amd64        GNU Standard C++ Library v3
ii  libsvn1:amd64              1.9.5-1+deb9u3                 amd64        Shared libraries used by Apache Subversion
ii  libsystemd0:amd64          232-25+deb9u11                 amd64        systemd utility library
ii  libtasn1-6:amd64           4.10-1.1+deb9u1                amd64        Manage ASN.1 structures (runtime)
ii  libtinfo5:amd64            6.0+20161126-1+deb9u2          amd64        shared low-level terminfo library for terminal handling
ii  libudev1:amd64             232-25+deb9u11                 amd64        libudev shared library
ii  libunistring0:amd64        0.9.6+really0.9.3-0.1          amd64        Unicode string library for C
ii  libustr-1.0-1:amd64        1.0.4-6                        amd64        Micro string library: shared library
ii  libuuid1:amd64             2.29.2-1+deb9u1                amd64        Universally Unique ID library
ii  login                      1:4.4-4.1                      amd64        system login tools
ii  lsb-base                   9.20161125                     all          Linux Standard Base init script functionality
ii  mawk                       1.3.3-17+b3                    amd64        a pattern scanning and text processing language
ii  mercurial                  4.0-1+deb9u1                   amd64        easy-to-use, scalable distributed version control system
ii  mercurial-common           4.0-1+deb9u1                   all          easy-to-use, scalable distributed version control system (common files)
ii  mime-support               3.60                           all          MIME files 'mime.types' & 'mailcap', and support programs
ii  mount                      2.29.2-1+deb9u1                amd64        tools for mounting and manipulating filesystems
ii  multiarch-support          2.24-11+deb9u4                 amd64        Transitional package to ensure multiarch compatibility
ii  ncurses-base               6.0+20161126-1+deb9u2          all          basic terminal type definitions
ii  ncurses-bin                6.0+20161126-1+deb9u2          amd64        terminal-related programs and man pages
ii  netbase                    5.4                            all          Basic TCP/IP networking system
ii  openssh-client             1:7.4p1-10+deb9u6              amd64        secure shell (SSH) client, for secure access to remote machines
ii  openssl                    1.1.0j-1~deb9u1                amd64        Secure Sockets Layer toolkit - cryptographic utility
ii  passwd                     1:4.4-4.1                      amd64        change and administer password and group data
ii  perl                       5.24.1-3+deb9u5                amd64        Larry Wall's Practical Extraction and Report Language
ii  perl-base                  5.24.1-3+deb9u5                amd64        minimal Perl system
ii  perl-modules-5.24          5.24.1-3+deb9u5                all          Core Perl modules
ii  pinentry-curses            1.0.0-2                        amd64        curses-based PIN or pass-phrase entry dialog for GnuPG
ii  procps                     2:3.3.12-3+deb9u1              amd64        /proc file system utilities
ii  python                     2.7.13-2                       amd64        interactive high-level object-oriented language (default version)
ii  python-bzrlib              2.7.0+bzr6619-7+deb9u1         amd64        distributed version control system - python library
ii  python-configobj           5.0.6-2                        all          simple but powerful config file reader and writer for Python 2
ii  python-minimal             2.7.13-2                       amd64        minimal subset of the Python language (default version)
ii  python-six                 1.10.0-3                       all          Python 2 and 3 compatibility library (Python 2 interface)
ii  python2.7                  2.7.13-2+deb9u3                amd64        Interactive high-level object-oriented language (version 2.7)
ii  python2.7-minimal          2.7.13-2+deb9u3                amd64        Minimal subset of the Python language (version 2.7)
ii  readline-common            7.0-3                          all          GNU readline and history libraries, common files
ii  sed                        4.4-1                          amd64        GNU stream editor for filtering/transforming text
ii  sensible-utils             0.0.9+deb9u1                   all          Utilities for sensible alternative selection
ii  subversion                 1.9.5-1+deb9u3                 amd64        Advanced version control system
ii  sysvinit-utils             2.88dsf-59.9                   amd64        System-V-like utilities
ii  tar                        1.29b-1.1                      amd64        GNU version of the tar archiving utility
ii  tzdata                     2019a-0+deb9u1                 all          time zone and daylight-saving time data
ii  ucf                        3.0036                         all          Update Configuration File(s): preserve user changes to config files
ii  unzip                      6.0-21+deb9u1                  amd64        De-archiver for .zip files
ii  util-linux                 2.29.2-1+deb9u1                amd64        miscellaneous system utilities
ii  wget                       1.18-5+deb9u3                  amd64        retrieves files from the web
ii  xz-utils                   5.2.2-1.2+b1                   amd64        XZ-format compression utilities
ii  zlib1g:amd64               1:1.2.8.dfsg-5                 amd64        compression library - runtime

解决方案如下:

在2019年5月22日,openjdk家伙改变了他们创建基本图像的方式。这样,他们现在可以手动下载镜像并将其解压缩到安装文件夹中。因此,dpkg未列出安装,并将与jdk相关的软件包标记为不兼容。

https://github.com/docker-library/openjdk/commit/3eb0351b208d739fac35345c85e3c6237c2114ec#diff-fef076ee1e5f270f2c5a93d075150919