skip to Main Content

I have expect script that I need to run under RedHat UBI 8 container. I’m trying to install expect via snap package manager, but I have problem starting snapd.
After issuing systemctl enable --now snapd.socket I get:

System has not been booted with systemd as init system (PID 1). Can't operate.
Failed to connect to bus: Host is down

Can be expect installed into RedHat UBI 8 without snap?

My Dockerfile so far:

FROM registry.access.redhat.com/ubi8/ubi

RUN dnf install https://dl.fedoraproject.org/pub/epel/epel-release-latest-8.noarch.rpm -y && 
    dnf install http://rpms.remirepo.net/enterprise/remi-release-8.rpm -y && 
    dnf update -y && 
    dnf install -y wget && 
    wget http://mirror.centos.org/centos/6/os/x86_64/Packages/squashfs-tools-4.0-5.el6.x86_64.rpm && 
    dnf install squashfs-tools-4.0-5.el6.x86_64.rpm -y && 
    wget http://mirror.centos.org/centos/8/BaseOS/x86_64/os/Packages/bash-completion-2.7-5.el8.noarch.rpm && 
    dnf install -y bash-completion-2.7-5.el8.noarch.rpm && 
    dnf install snapd -y && 
    systemctl enable --now snapd.socket && 
    ln -s /var/lib/snapd/snap /snap && 
    snap install expect

2

Answers


  1. The expect package is part of the base rhel 8 repositories. If your host has a valid RHEL subscription, your container should have access to all the RHEL 8 repositories, which means you can simply install expect inside the container:

    dnf -y install expect
    

    If you don’t have a valid subscription, maybe just use a CentOS based image instead?


    The simplest solution is either (a) use a base image without licensing encumbrances, or (b) buy a license for the software you’re using. If your clients are unwilling to do either of those things, you do have some alternatives:

    You could make the CentOS repository available under ubi. Create a repo configuration pointing at the CentOS 8 repositories:

    [centos8-base]
    name = CentOS 8 Base OS
    baseurl = http://mirror.centos.org/centos/8/BaseOS/x86_64/os/
    gpgcheck = 0
    enabled = 0
    

    And use this to install expect:

    FROM registry.access.redhat.com/ubi8/ubi
    
    COPY centos8.repo /etc/yum.repos.d/centos8.repo
    RUN dnf -y --enablerepo=centos8-base install expect
    
    Login or Signup to reply.
  2. Update Aug 18 – 2021

    Previous answer was correct however dnf has now been hanged to microdnf

    so the command becomes:

    FROM registry.access.redhat.com/ubi8/ubi
    
    COPY centos8.repo /etc/yum.repos.d/centos8.repo
    RUN microdnf -y --enablerepo=centos8-base install expect
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search