Dockerfile | ERROR: failed to solve: process "/bin/sh -c apt-get install libc6:i386" did not complete successfully: exit code: 1

I want to install libc6:i386 through the dockfile, but I don’t know why it always fails. When executing sudo docker run -it --rm debian:bookworm bash and entering the container, I use apt search libc6-i386 to search, which can find libc6:i386.

#1 errors:

[+] Building 75.6s (10/25)                                                                                                                                                      docker:default
 => [internal] load build definition from Dockerfile                                                                                                                                      0.0s
 => => transferring dockerfile: 1.27kB                                                                                                                                                    0.0s
 => [internal] load .dockerignore                                                                                                                                                         0.0s
 => => transferring context: 2B                                                                                                                                                           0.0s
 => [internal] load metadata for docker.io/library/debian:bookworm                                                                                                                       31.8s
 => [ 1/21] FROM docker.io/library/debian:bookworm@sha256:fab22df37377621693c68650b06680c0d8f7c6bf816ec92637944778db3ca2c0                                                                0.0s
 => [internal] load build context                                                                                                                                                         0.0s
 => => transferring context: 931B                                                                                                                                                         0.0s
 => CACHED [ 2/21] RUN dpkg --add-architecture i386                                                                                                                                       0.0s
 => CACHED [ 3/21] RUN apt-get update -y                                                                                                                                                  0.0s
 => CACHED [ 4/21] RUN apt-get upgrade -y                                                                                                                                                 0.0s
 => [ 5/21] RUN apt-get install net-tools  uml-utilities     bridge-utils    iputils-ping     python3     vim     openssh-server     openssh-client     curl     gpg     psmisc     sam  41.9s
 => ERROR [ 6/21] RUN apt-get install libc6:i386                                                                                                                                          1.9s
------
 > [ 6/21] RUN apt-get install libc6:i386:
0.312 Reading package lists...
1.238 Building dependency tree...
1.456 Reading state information...
1.728 The following additional packages will be installed:
1.731   gcc-12-base:i386 libgcc-s1:i386 libidn2-0:i386 libunistring2:i386
1.734 Suggested packages:
1.734   glibc-doc:i386 libc-l10n:i386 locales:i386 libnss-nis:i386
1.734   libnss-nisplus:i386
1.791 The following NEW packages will be installed:
1.793   gcc-12-base:i386 libc6:i386 libgcc-s1:i386 libidn2-0:i386 libunistring2:i386
1.811 0 upgraded, 5 newly installed, 0 to remove and 0 not upgraded.
1.811 Need to get 3283 kB of archives.
1.811 After this operation, 15.0 MB of additional disk space will be used.
1.811 Do you want to continue? [Y/n] Abort.
------
Dockerfile:25
--------------------
  23 |         -y
  24 |
  25 | >>> RUN apt-get install libc6:i386
  26 |     RUN apt-get install lib32stdc++6
  27 |
--------------------
ERROR: failed to solve: process "/bin/sh -c apt-get install libc6:i386" did not complete successfully: exit code: 1

#2 Dockerfile:

  1 #FROM debian:latest
  2 FROM debian:bookworm
  3 # for 32bit
  4 RUN dpkg --add-architecture i386
  5
  6 RUN apt-get update -y
  7 RUN apt-get upgrade -y
  8 RUN apt-get install net-tools 
  9     uml-utilities 
 10     bridge-utils
 11     iputils-ping 
 12     python3 
 13     vim 
 14     openssh-server 
 15     openssh-client 
 16     curl 
 17     gpg 
 18     psmisc 
 19     samba 
 20     samba-common 
 21     redis 
 22     unzip 
 23     -y
 24
 25 #RUN apt-get install libc6:i386
 26 RUN apt-get install lib32stdc++6

#3 test:

debian12@gyz:~/share/v4vc$ sudo docker run -it --rm debian:bookworm bash
root@491b483e7f0a:/#
root@491b483e7f0a:/# apt search libc6-i386
Sorting... Done
Full Text Search... Done
libc6-i386/stable-security 2.36-9+deb12u3 amd64
  GNU C Library: 32-bit shared libraries for AMD64

libc6-i386-amd64-cross/stable 2.36-8cross1 all
  GNU C Library: 32-bit shared libraries for AMD64 (for cross-compiling)

libc6-i386-cross/stable 2.36-8cross1 all
  GNU C Library: Shared libraries (for cross-compiling)

libc6-i386-x32-cross/stable 2.36-8cross1 all
  GNU C Library: 32-bit shared libraries for AMD64 (for cross-compiling)
Asked By: ABeginner

||

The problem is this:

1.811 Do you want to continue? [Y/n] Abort.

apt wants confirmation before continuing, but since it’s running non-interactively, it takes the safe option and exits. Not only that, it exits with an error, so the whole build fails.

You need to tell apt to assume “yes” answers; that’s what the -y option used in the previous commands is for.

RUN apt-get install -y libc6:i386
RUN apt-get install -y lib32stdc++6

or

RUN apt-get install -y libc6:i386 lib32stdc++6
Answered By: Stephen Kitt
Categories: Answers Tags: , ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.