Fixing CentOS 7 systemd conflicts with docker

Wednesday , 16, December 2015 2 Comments

With the release of 7.2, we’ve seen a rise in bugs filed for container build failures in docker. Not to worry, we have an explanation for what’s going on, and the solution for how to fix it.

The Problem:

You fire off a docker build, and instead of a shiny new container, you end up with an error message similar to:

Transaction check error:
file /usr/lib64/libsystemd-daemon.so.0 from install of systemd-libs-219-19.el7.x86_64 conflicts with file from package systemd-container-libs-208.20-6.el7.centos.x86_64
file /usr/lib64/libsystemd-id128.so.0 from install of systemd-libs-219-19.el7.x86_64 conflicts with file from package systemd-container-libs-208.20-6.el7.centos.x86_64
file /usr/lib64/libsystemd-journal.so.0 from install of systemd-libs-219-19.el7.x86_64 conflicts with file from package systemd-container-libs-208.20-6.el7.centos.x86_64
file /usr/lib64/libsystemd-login.so.0 from install of systemd-libs-219-19.el7.x86_64 conflicts with file from package systemd-container-libs-208.20-6.el7.centos.x86_64
file /usr/lib64/libudev.so.1 from install of systemd-libs-219-19.el7.x86_64 conflicts with file from package systemd-container-libs-208.20-6.el7.centos.x86_64
file /usr/lib64/security/pam_systemd.so from install of systemd-libs-219-19.el7.x86_64 conflicts with file from package systemd-container-libs-208.20-6.el7.centos.x86_64

This is due to the transition from systemd-container-* packages to actual systemd. For some reason, the upstream package doesn’t obsolete or conflict, and so you’ll get errors when installing packages.

The fix:

The fix for this issue is very simple. Do a fresh docker pull of the base container.

# docker pull centos:latest

or

# docker pull centos:7

Your base container will now be at the appropriate level, and won’t have this conflict on package installs so you can simply run your docker build again and it will work.

But I have to use 7.1.1503!

If for some reason you must use a point-in-time image like 7.1.1503, then a package swap will resolve things for you. 7.1.1503 comes with fakesystemd, which you must exchange for systemd. To do this, execute the following command in your Dockerfile, prior to installing any packages:

RUN yum clean all && yum swap fakesystemd systemd

This will ensure you get the current package data, and will replace the fakesystemd package which is no longer needed. That’s all there is to solving the file conflicts and systemd dependency issues for CentOS base containers.

 

2 thoughts on “ : Fixing CentOS 7 systemd conflicts with docker”
  • Ryan Fraser says:

    Thanks for the fix! I was kind of thinking i had borked something pretty badly in my setup, thankfully it was just the image I was pulling. Glad Google indexed this post quickly as well!

    Cheers!

  • gpolaert says:

    Thanks, you need to force the “yes” flag.
    RUN yum clean all && yum swap -y fakesystemd systemd

  • Please give us your valuable comment

    Your email address will not be published. Required fields are marked *