Sunday, September 4, 2022

Docker/Ubuntu: Installing the latest cmake on Docker Image

This post demonstrates how to install the latest version of cmake during docker build targetting an Ubuntu 20.04 image. The Dockerfile for such an image starts with:

FROM ubuntu:20.04

A previous post, Ubuntu: Upgrade to the latest cmake, demonstrated the bash commands that could be used to install the latest version of cmake on an Ubuntu 20.04.4 LTS image. Fundamentally these are the same commands that could be used to install cmake on a Docker image during build. From the previously demonstrated script, the sudo commands were removed a few additional apt-get commands are required.

A sample Dockerfile that installs the latest cmake (currently 3.24.1) on an Ubuntu 20.04 image is follows:

FROM ubuntu:20.04


# Put your own Dockfile commands here

RUN apt-get update \
  && apt-get -y install build-essential \
  && apt-get install -y wget \
  && rm -rf /var/lib/apt/lists/* \
  && wget https://github.com/Kitware/CMake/releases/download/v3.24.1/cmake-3.24.1-Linux-x86_64.sh \
      -q -O /tmp/cmake-install.sh \
      && chmod u+x /tmp/cmake-install.sh \
      && mkdir /opt/cmake-3.24.1 \
      && /tmp/cmake-install.sh --skip-license --prefix=/opt/cmake-3.24.1 \
      && rm /tmp/cmake-install.sh \
      && ln -s /opt/cmake-3.24.1/bin/* /usr/local/bin


# Put your own Dockfile commands here

No comments :

Post a Comment