Skip to content
Advertisement

yum dependency resolution behaves differently in docker build vs docker run

It appears that yum’s dependency resolution behaves differently depending on whether it is invoked from the RUN statement of a Dockerfile, or from docker run.

Consider this Dockerfile:

JavaScript

The docker build fails on the last command. The full output is included below, but basically yum selects packages for both i386 and x86_64.

But running the same commands from docker run works! No packages for x86_64 are selected.

JavaScript

What could explain this strange behaviour?

And how to get the Dockerfile to build?

Environment

JavaScript

Output from docker build

JavaScript

Output from docker run

JavaScript

Advertisement

Answer

The reason is that the package manager relies on the information provided by the kernel (via uname(2)) to decide which versions of packages (for which target architecture) should it install. Though your base image has i386 environment inside, you still run the build on x86_64 kernel, so things become a bit tricky.

When you run the container using docker run, you pass through the entrypoint linux32 – a small program which asks the kernel to pretend that it runs on i386 hardware. However, when you run docker build, the entrypoint is not used by RUNs, so yum sees that it runs on x86_64 kernel, hence the mess with platforms. You may check this answer for more detailed explanation; the issue is pretty similar.

To build your image correctly (installing only i386 packages), run yum and other architecture-sensitive commands in RUNs under linux32, e.g.:

JavaScript
User contributions licensed under: CC BY-SA
6 People found this is helpful
Advertisement