Build and Run Docker Container
Build and Run Docker Container¶
Create a Dockerfile on RHEL 8.6 operating system. Internet access is required:
vi Dockerfile
The below Dockerfile is provided as an example for your reference. To make it work on your environment, perform the following:
Use your RHEL 8.6 subscription and license details.
Adjust the highlighted lines below to match the configuration details of your environment.
When building the Docker image, make sure
OCP_HOST_KERNEL_VER
andKERNEL_VER
versions are as close as possible. For example, see lines 3-4 highlighted below:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115
FROM redhat/ubi8:8.6 ARG KERNEL_VER=4.18.0-305.25.1.el8_4 ARG OCP_HOST_KERNEL_VER=4.18.0-305.28.1.el8_4.x86_64 LABEL description="RHEL 8.6 docker image for driver loading inside docker container" LABEL kernel="${KERNEL_VER}" ENV DEBIAN_FRONTEND=noninteractive ENV LC_CTYPE=en_US.UTF-8 ENV LANG=en_US.UTF-8 # needed for compiling kernel module on diferent host kernel (OS) ENV KVERSION="${KERNEL_VER}" RUN dnf install -y https://dl.fedoraproject.org/pub/epel/epel-release-latest-8.noarch.rpm RUN echo "[rhel-8-for-x86_64-baseos-source-rpms]" > /etc/yum.repos.d/rhel8_6.repo && \ echo "Red Hat Enterprise Linux 8 for x86_64 - BaseOS (Source RPMs)" >> /etc/yum.repos.d/rhel8_6.repo && \ echo "baseurl=https://cdn.redhat.com/content/dist/rhel8/$releasever/x86_64/baseos/source/SRPMS" >> /etc/yum.repos.d/rhel8_6.repo && \ echo 'enabled = 1' >> /etc/yum.repos.d/rhel8_6.repo && \ echo 'gpgcheck=0' >> /etc/yum.repos.d/rhel8_6.repo && \ echo 'gpgkey = file://<PATH_TO_RPM-GPG-KEY-redhat-release_FILE>' >> /etc/yum.repos.d/rhel8_6.repo && \ echo 'sslverify = 1' >> /etc/yum.repos.d/rhel8_6.repo && \ echo 'sslcacert = <PATH_TO/redhat-uep.pem>' >> /etc/yum.repos.d/rhel8_6.repo && \ echo 'sslclientkey = /etc/pki/entitlement/**************-key.pem' >> /etc/yum.repos.d/rhel8_6.repo && \ echo 'sslclientcert = /etc/pki/entitlement/*****************.pem' >> /etc/yum.repos.d/rhel8_6.repo && \ echo 'metadata_expire = 86400' >> /etc/yum.repos.d/rhel8_6.repo && \ echo 'enabled_metadata = 1' >> /etc/yum.repos.d/rhel8_6.repo RUN dnf install -y \ yum-utils \ vim-common \ git \ redhat-lsb-core \ cmake3 \ sudo \ rsync \ mlocate \ nfs-utils \ perl-ExtUtils-MakeMaker \ boost-program-options \ boost \ boost-devel \ boost-filesystem \ gcc \ gcc-c++ \ glibc \ glibc-headers \ glibc-devel \ cpp \ golang \ wget \ patch \ expect \ elfutils \ elfutils-devel \ elfutils-libelf \ elfutils-libelf-devel \ elfutils-libs \ perl-ExtUtils-MakeMaker \ rpm-sign \ rpmdevtools \ chrpath \ ncurses* \ curl-devel \ libarchive \ bc \ autoconf \ automake \ flex \ bison \ ncurses-devel \ pinentry \ zlib-devel \ libjpeg-devel \ yasm \ glibc-static \ boost-static \ libstdc++-static \ openssl \ openssl-devel \ clang \ llvm \ libao \ libao-devel \ libmad \ libmad-devel \ libcmocka \ libcmocka-devel \ sox \ sox-devel \ curl \ protobuf \ protobuf-compiler \ protobuf-devel \ pciutils \ kernel-${KERNEL_VER} \ kernel-devel-${KERNEL_VER} \ kernel-headers-${KERNEL_VER} \ lapack-devel \ blas-devel RUN rm -f /etc/yum.repos.d/rhel8_6.repo && rm -rf /tmp/* && \ dnf clean all && rm -rf /var/cache/yum && rm -rf /var/cache/dnf RUN cd /lib/modules && \ ln -s 4.18.0-305.25.1.el8_4.x86_64 ${OCP_HOST_KERNEL_VER} # Set the right timezone, stil need to overmount /etc/localtime from host RUN echo "Asia/Jerusalem" > /etc/timezone && \ sed -i s/Defaults/#Defaults/g /etc/sudoers && \ echo 'coreos ALL=(ALL) NOPASSWD:ALL' >> /etc/sudoers && \ mkdir -p /etc/udev/rules.d/ && \ echo 'KERNEL=="hl[0-9sv]*", MODE="0666"' >> /etc/udev/rules.d/habana.rules CMD [ "/bin/bash" ]
Note
To load the Intel Gaudi driver properly, make sure to use
redhat/ubi8:8.6
base image to create the Docker image.Build and run the Docker container. Make sure the Docker image is built on the same operating system where the Dockerfile was created:
docker build -f Dockerfile -t hl-core-os:rhel8.6 .
Once the build is finished, upload the image to your local Docker registry:
docker login <your docker registry URL> docker push <your docker registry URL/path (where your docker is stored) images/hl-core-os:rhel8.6>
Note
Make sure your OCP host has access to above Docker registry.
Run the Docker container with the below command:
sudo podman run --name hl-rhel-coreos --entrypoint=bash --privileged=true -it <your docker registry URL/path_where_your_docker_image_stored/hl-core-os:rhel8.6>
After running the above command, the Docker prompt CLI will open. You are now inside the running Docker container.