hongyi-zhao / dockerfile

Use x11docker to run the Deepin desktop applications such as WeChat and QQ in the Docker container.
MIT License
4 stars 0 forks source link

The following error will be triggered when building the Deepin desktop Docker image: `"E: Sub-process /usr/bin/dpkg returned an error code (1)"`. #1

Closed wnark closed 2 years ago

wnark commented 2 years ago
[root@VM-4-9-centos docker]# docker run --rm -i hadolint/hadolint < Dockerfile
Unable to find image 'hadolint/hadolint:latest' locally
latest: Pulling from hadolint/hadolint
6449f89468e7: Pull complete 
Digest: sha256:93f0afd12c3be5d732227c0226dd8e7bb84f79319a773d7f8519e55f958ba415
Status: Downloaded newer image for hadolint/hadolint:latest
-:2 DL3006 warning: Always tag the version of an image explicitly
-:13 DL3027 warning: Do not use apt as it is meant to be a end-user tool, use apt-get or apt-cache instead
-:13 SC2028 info: echo may not expand escape sequences. Use printf.
-:32 DL4000 error: MAINTAINER is deprecated
-:43 DL3009 info: Delete the apt-get lists after installing something

Using docker build -t docker-deepin . also fails to build

[root@VM-4-9-centos docker]# docker build -t docker-deepin .
Sending build context to Docker daemon  5.632kB
Step 1/10 : FROM debian AS builder
latest: Pulling from library/debian
dbba69284b27: Pull complete 
Digest: sha256:87eefc7c15610cca61db5c0fd280911c6a737c0680d807432c0bd80cd0cca39b
Status: Downloaded newer image for debian:latest
 ---> d69c6cd3a20d
Step 2/10 : ARG     DEEPIN_RELEASE     DEEPIN_REPOSITORY     OPENSOURCE_MIRROR
 ---> Running in 1e62851e61ac
Removing intermediate container 1e62851e61ac
 ---> 2440d33fd5fe
Step 3/10 : RUN     sed -ri "s|^(deb(-src)?[[:blank:]]+https?://)([^/]+)|\1${OPENSOURCE_MIRROR}|" /etc/apt/sources.list &&     apt update && apt install -y debootstrap &&     ln -sf /usr/share/debootstrap/scripts/stable /usr/share/debootstrap/scripts/$DEEPIN_RELEASE &&     debootstrap --no-check-gpg --arch=$(dpkg --print-architecture) --include=bash $DEEPIN_RELEASE /rootfs $DEEPIN_REPOSITORY &&     echo "deb [by-hash=force] ${DEEPIN_REPOSITORY} ${DEEPIN_RELEASE} main contrib non-free\ndeb-src ${DEEPIN_REPOSITORY} ${DEEPIN_RELEASE} main contrib non-free\n" > /rootfs/etc/apt/sources.list &&     rm -rf /rootfs/var/cache/* /rootfs/tmp/* /rootfs/var/log/*
 ---> Running in 7561e95ca8e6

WARNING: apt does not have a stable CLI interface. Use with caution in scripts.

Ign:1 http:/debian-security bullseye-security InRelease
Ign:2 http:/debian bullseye-updates InRelease
Err:3 http:/debian-security bullseye-security Release
  Undetermined Error
Err:4 http:/debian bullseye-updates Release
  Undetermined Error
Ign:5 http:/debian bullseye InRelease
Err:6 http:/debian bullseye Release
  Undetermined Error
Reading package lists...
E: The repository 'http:/debian-security bullseye-security Release' does not have a Release file.
E: The repository 'http:/debian bullseye-updates Release' does not have a Release file.
E: The repository 'http:/debian bullseye Release' does not have a Release file.
The command '/bin/sh -c sed -ri "s|^(deb(-src)?[[:blank:]]+https?://)([^/]+)|\1${OPENSOURCE_MIRROR}|" /etc/apt/sources.list &&     apt update && apt install -y debootstrap &&     ln -sf /usr/share/debootstrap/scripts/stable /usr/share/debootstrap/scripts/$DEEPIN_RELEASE &&     debootstrap --no-check-gpg --arch=$(dpkg --print-architecture) --include=bash $DEEPIN_RELEASE /rootfs $DEEPIN_REPOSITORY &&     echo "deb [by-hash=force] ${DEEPIN_REPOSITORY} ${DEEPIN_RELEASE} main contrib non-free\ndeb-src ${DEEPIN_REPOSITORY} ${DEEPIN_RELEASE} main contrib non-free\n" > /rootfs/etc/apt/sources.list &&     rm -rf /rootfs/var/cache/* /rootfs/tmp/* /rootfs/var/log/*' returned a non-zero code: 100
wnark commented 2 years ago

image

hongyi-zhao commented 2 years ago

Please refer to the steps used in build.sh. You should first source the environment. I've written some guidelines here that maybe you should read.

The results of my test below are for your reference:

$ . deepin/environment 
$ docker run --rm -i hadolint/hadolint < deepin/desktop/Dockerfile
-:2 DL3006 warning: Always tag the version of an image explicitly
-:13 DL3027 warning: Do not use apt as it is meant to be a end-user tool, use apt-get or apt-cache instead
-:13 SC2028 info: echo may not expand escape sequences. Use printf.
-:42 DL3009 info: Delete the apt-get lists after installing something

$ docker run --rm -i hadolint/hadolint < deepin/wine/Dockerfile
-:3 DL3006 warning: Always tag the version of an image explicitly
-:37 DL3009 info: Delete the apt-get lists after installing something
-:37 SC2028 info: echo may not expand escape sequences. Use printf.
-:59 DL3009 info: Delete the apt-get lists after installing something
-:59 SC2028 info: echo may not expand escape sequences. Use printf.

$ dockerfilelint < deepin/desktop/Dockerfile

File:   <stdin>
Issues: 4

Line 2: FROM debian AS builder
Issue  Category      Title                 Description
    1  Clarity       Base Image Missing    Base images should specify a tag to use.
                     Tag

Line 42: RUN apt-get update && \
Issue  Category      Title                 Description
    2  Possible Bug  Use Of sudo Is Not    Use of `sudo` is not allowed in a Dockerfile.  From the official
                     Allowed               document [Best practices for writing
                                           Dockerfiles](https://docs.docker.com/engine/userguide/eng-image/doc
                                           kerfile_best-practices/):
                                           > You should avoid installing or using `sudo` since it has
                                           unpredictable TTY and signal-forwarding behavior that can cause
                                           more problems than it solves.
                                           > If you absolutely need functionality similar to `sudo` (e.g.,
                                           initializing the daemon as root but running it as non-root), you
                                           may be able to use `gosu`.
    3  Optimization  apt-get update with   Use of apt-get update should be paired with rm -rf
                     matching cache rm     /var/lib/apt/lists/* in the same layer.
    4  Optimization  apt-get update        All instances of `apt-get update` should have the `apt-get install`
                     without matching      commands on the same line to reduce image size.
                     apt-get install

$ dockerfilelint < deepin/wine/Dockerfile

File:   <stdin>
Issues: 5

Line 3: FROM $DEEPIN_BASE_IMAGE
Issue  Category      Title                 Description
    1  Clarity       Base Image Missing    Base images should specify a tag to use.
                     Tag

Line 37: RUN apt-key adv --keyserver hkp://keyserver.ubuntu.com --recv-keys 1C30362C0A53D5BB && \
Issue  Category      Title                 Description
    2  Optimization  apt-get update with   Use of apt-get update should be paired with rm -rf
                     matching cache rm     /var/lib/apt/lists/* in the same layer.
    3  Optimization  apt-get update        All instances of `apt-get update` should have the `apt-get install`
                     without matching      commands on the same line to reduce image size.
                     apt-get install

Line 59: RUN apt-get update && \
Issue  Category      Title                 Description
    4  Optimization  apt-get update with   Use of apt-get update should be paired with rm -rf
                     matching cache rm     /var/lib/apt/lists/* in the same layer.
    5  Optimization  apt-get update        All instances of `apt-get update` should have the `apt-get install`
                     without matching      commands on the same line to reduce image size.
                     apt-get install
wnark commented 2 years ago

Please refer to the steps used in build.sh. You should first source the environment. I've written some guidelines here that maybe you should read.

The results of my test below are for your reference:

$ . deepin/environment 
$ docker run --rm -i hadolint/hadolint < deepin/desktop/Dockerfile
-:2 DL3006 warning: Always tag the version of an image explicitly
-:13 DL3027 warning: Do not use apt as it is meant to be a end-user tool, use apt-get or apt-cache instead
-:13 SC2028 info: echo may not expand escape sequences. Use printf.
-:42 DL3009 info: Delete the apt-get lists after installing something

$ docker run --rm -i hadolint/hadolint < deepin/wine/Dockerfile
-:3 DL3006 warning: Always tag the version of an image explicitly
-:37 DL3009 info: Delete the apt-get lists after installing something
-:37 SC2028 info: echo may not expand escape sequences. Use printf.
-:59 DL3009 info: Delete the apt-get lists after installing something
-:59 SC2028 info: echo may not expand escape sequences. Use printf.

$ dockerfilelint < deepin/desktop/Dockerfile

File:   <stdin>
Issues: 4

Line 2: FROM debian AS builder
Issue  Category      Title                 Description
    1  Clarity       Base Image Missing    Base images should specify a tag to use.
                     Tag

Line 42: RUN apt-get update && \
Issue  Category      Title                 Description
    2  Possible Bug  Use Of sudo Is Not    Use of `sudo` is not allowed in a Dockerfile.  From the official
                     Allowed               document [Best practices for writing
                                           Dockerfiles](https://docs.docker.com/engine/userguide/eng-image/doc
                                           kerfile_best-practices/):
                                           > You should avoid installing or using `sudo` since it has
                                           unpredictable TTY and signal-forwarding behavior that can cause
                                           more problems than it solves.
                                           > If you absolutely need functionality similar to `sudo` (e.g.,
                                           initializing the daemon as root but running it as non-root), you
                                           may be able to use `gosu`.
    3  Optimization  apt-get update with   Use of apt-get update should be paired with rm -rf
                     matching cache rm     /var/lib/apt/lists/* in the same layer.
    4  Optimization  apt-get update        All instances of `apt-get update` should have the `apt-get install`
                     without matching      commands on the same line to reduce image size.
                     apt-get install

$ dockerfilelint < deepin/wine/Dockerfile

File:   <stdin>
Issues: 5

Line 3: FROM $DEEPIN_BASE_IMAGE
Issue  Category      Title                 Description
    1  Clarity       Base Image Missing    Base images should specify a tag to use.
                     Tag

Line 37: RUN apt-key adv --keyserver hkp://keyserver.ubuntu.com --recv-keys 1C30362C0A53D5BB && \
Issue  Category      Title                 Description
    2  Optimization  apt-get update with   Use of apt-get update should be paired with rm -rf
                     matching cache rm     /var/lib/apt/lists/* in the same layer.
    3  Optimization  apt-get update        All instances of `apt-get update` should have the `apt-get install`
                     without matching      commands on the same line to reduce image size.
                     apt-get install

Line 59: RUN apt-get update && \
Issue  Category      Title                 Description
    4  Optimization  apt-get update with   Use of apt-get update should be paired with rm -rf
                     matching cache rm     /var/lib/apt/lists/* in the same layer.
    5  Optimization  apt-get update        All instances of `apt-get update` should have the `apt-get install`
                     without matching      commands on the same line to reduce image size.
                     apt-get install

Thanks for your reply, I am using the script here cd deepin && bash build.sh The build still fails. I am using Tencent Cloud's US cloud host, so there should be no problems due to poor network. image

wnark commented 2 years ago
E: Sub-process /usr/bin/dpkg returned an error code (1)
The command '/bin/sh -c apt-get update &&     env DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends --no-install-suggests         sudo apt-transport-https ca-certificates dbus-x11 deepin-keyring gnupg libcups2         libpulse0 libxv1 locales-all mesa-utils mesa-utils-extra procps psmisc xdg-utils         x11-xkb-utils x11-xserver-utils         iproute2 iptables iputils-ping iputils-tracepath         openssh-server openssh-client dnsutils net-tools netcat traceroute         ncat socat connect-proxy haproxy tcpdump pv iftop iperf3 firefox-esr         build-essential gcc make cmake git curl gawk         apt-file apt-transport-https apt-utils gdebi synaptic         bash-completion libpulse0 pulseaudio         uuid equivs unrar lsb-release         xfonts-wqy fonts-wqy-microhei fonts-wqy-zenhei nano gedit gedit-plugins vim xclip xsel         deepin-app-store         deepin-appstore         deepin-home-appstore-daemon         deepin-desktop-server         deepin-default-settings         dde-desktop         dde-dock         dde-launcher         dde-control-center         startdde         deepin-artwork         dde-file-manager         dde-qt5integration         deepin-wallpapers         fonts-noto         dde-introduction         dde-kwin         deepin-screensaver         dde-calendar         deepin-terminal &&         apt-get clean' returned a non-zero code: 100
Sending build context to Docker daemon  27.65kB
Step 1/13 : ARG DEEPIN_BASE_IMAGE
Step 2/13 : FROM $DEEPIN_BASE_IMAGE
pull access denied for hongyizhao/deepin-desktop, repository does not exist or may require 'docker login': denied: requested access to the resource is denied

I am using centos7 to execute it. Does the docker build still need to be exactly the same as the system you are using?

hongyi-zhao commented 2 years ago

The hongyizhao/deepin-desktop image must be built first, on which the hongyizhao/deepin-wine is built:

$ docker images | grep hongyizhao
hongyizhao/deepin-desktop   apricot   ea0103aee7b6   3 months ago    3.68GB
hongyizhao/deepin-wine      apricot   9f1125b8ef90   3 months ago    5.43GB

Does the docker build still need to be exactly the same as the system you are using?

Absolutely not. See here for some explanations.

Your build log shows that some additional packages that are not included in the Dockerfile are required:

image

This is a tricky thing. I tried to tweak the Dockerfile, but still failed to solve the problem. So, the only solution I can think of is to analyze the software packages that Deepin Desktop depends on from the Deepin ISO or installed Deepin virtual machine.

wnark commented 2 years ago

Thank you for your analysis, I will try to use dockerfile to make a minimal Ubuntu desktop, and then install the packages I need step by step.

hongyi-zhao commented 2 years ago

I will try to use dockerfile to make a minimal Ubuntu desktop,

As I've commented, due to the guest OS Deepin is a Linux OS, the host OS can be any Linux distribution in principle.

and then install the packages I need step by step.

I've fixed the problem discussed here. You can see if it works on your machine as well. Please refer to the following information about the docker images and the screenshots when running them through x11docker:

$ docker images | grep hongyi
hongyizhao/deepin-wine      apricot   050ee3894351   59 minutes ago      5.91GB
hongyizhao/deepin-desktop   apricot   525ff1374829   About an hour ago   4.35GB

image

image

image

wnark commented 2 years ago

image Hello, there are still some problems in the build phase.

git clone https://github.com/hongyi-zhao/dockerfile.git
cd dockerfile/
cd deepin
chmod 777 -R *
./build.sh

Then report an error: E: Package 'shutter' has no installation candidate

hongyi-zhao commented 2 years ago

Thank you for reporting this problem. The shutter tool does not exist in the APT repository, but exists in Personal Package Archives (PPAs) and its GitHub repository.

I fixed the problem. You can try again.

wnark commented 2 years ago

emmm image There is still a problem here

sr0: Failed to write 'change' to '/sys/devices/pci0000:00/0000:00:01.1/ata1/host0/target0:0:1/0:0:1:0/block/sr0/uevent': Read-only file system
dpkg: error processing package udisks2 (--configure):
 installed udisks2 package post-installation script subprocess returned error exit status 1
Processing triggers for man-db (2.8.5-2) ...
Processing triggers for dbus (1.12.20-0+deb10u1+rebuild) ...
Processing triggers for libc-bin (2.28.19-1+dde) ...
Errors were encountered while processing:
 udisks2
E: Sub-process /usr/bin/dpkg returned an error code (1)
Setting up udisks2 (2.8.1.1-1+deepin) ...

WARNING: apt does not have a stable CLI interface. Use with caution in scripts.

Reading package lists...
Building dependency tree...
Reading state information...
0 upgraded, 0 newly installed, 0 to remove and 2 not upgraded.
Removing intermediate container 743898a9fa7f
 ---> 9c401e1cc3b3
Step 10/11 : RUN apt-get -y update &&         deepin-app-store         deepin-appstore         deepin-home-appstore-daemon env DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends --no-install-suggests deepin-desktop-server deepin-default-settings dde-desktop dde-dock dde-launcher dde-control-center startdde deepin-artwork dde-file-manager dde-qt5integration deepin-wallpapers fonts-noto dde-introduction dde-kwin deepin-screensaver dde-calendar deepin-terminal && apt-get clean
 ---> Running in 9379789297e2
Hit:1 https://mirrors.tuna.tsinghua.edu.cn/deepin apricot InRelease
Reading package lists...
/bin/sh: 1: deepin-app-store: not found
The command '/bin/sh -c apt-get -y update &&         deepin-app-store         deepin-appstore         deepin-home-appstore-daemon env DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends --no-install-suggests deepin-desktop-server deepin-default-settings dde-desktop dde-dock dde-launcher dde-control-center startdde deepin-artwork dde-file-manager dde-qt5integration deepin-wallpapers fonts-noto dde-introduction dde-kwin deepin-screensaver dde-calendar deepin-terminal && apt-get clean' returned a non-zero code: 127
Sending build context to Docker daemon      1MB
Step 1/13 : ARG DEEPIN_BASE_IMAGE
Step 2/13 : FROM $DEEPIN_BASE_IMAGE
pull access denied for hongyizhao/deepin-desktop, repository does not exist or may require 'docker login': denied: requested access to the resource is denied
hongyi-zhao commented 2 years ago

Fixed, please try again.

wnark commented 2 years ago

image There are still some minor issues, but it looks like it has been successfully built at this stage

backend_syslog.go:45: <info> syslog is not available: Unix syslog delivery error
backend_syslog.go:45: <info> syslog is not available: Unix syslog delivery error
backend_syslog.go:45: <info> syslog is not available: Unix syslog delivery error
backend_syslog.go:45: <info> syslog is not available: Unix syslog delivery error
<info> upgradable.go:218: stat /etc/apt/sources.list.d/security.list: no such file or directory
backend_syslog.go:45: <info> syslog is not available: Unix syslog delivery error
backend_syslog.go:45: <info> syslog is not available: Unix syslog delivery error
backend_syslog.go:45: <info> syslog is not available: Unix syslog delivery error
backend_syslog.go:45: <info> syslog is not available: Unix syslog delivery error
E: lstat /lastore/override/desktop2uaid: no such file or directory

WARNING: apt does not have a stable CLI interface. Use with caution in scripts.

Removing intermediate container 09c23fb03c01
hongyi-zhao commented 2 years ago

These are messages and warnings that, as commented here, are harmless.