Skip to content

Containers

Anderson Chauphan edited this page May 6, 2024 · 5 revisions

Quick Start

Assumptions

  • You are sitting on a machine with a container engine installed (usually Docker or Podman)
  • You have a local clone of Trilinos located at ${HOME}/Trilinos
  • You have run cd ${HOME}/Trilinos/package/framework && ./get_dependencies.sh --container
    • This step is only necessary if you will be using GenConfig

Commands

# Pull image from registry
docker pull registry-ex.sandia.gov/trilinos-project/trilinos-containers/dev_ubi8_intel2023_intelmpi2021:latest

# Start a container from the image, with your code project mounted
docker run --rm -it --mount type=bind,src=${HOME}/Trilinos,dst=/root/Trilinos registry-ex.sandia.gov/trilinos-project/trilinos-containers/dev_ubi8_intel2023_intelmpi2021:latest

# Build and test Trilinos however you'd like.  Below are instructions if you wish to use GenConfig
cd ~
mkdir build
cd build
source ../Trilinos/packages/framework/GenConfig/gen_config.sh --force rhel8_oneapi-intelmpi_release-debug_shared_no-kokkos-arch_no-asan_no-complex_fpic_mpi_no-pt_no-rdc_no-uvm_deprecated-on_all /root/Trilinos
ninja
ctest

For more information about developing with persistent data in containers, read here.

Getting Started

Docker Getting Started guide

tldr it helps to think of a Docker image as a program on your disk e.g., /bin/ls. Following that analogy, you can think of a Docker container as a running process e.g., when you type ls ~.

Building an image is typically done by passing a Dockerfile to Docker as illustrated here. The Dockerfile is text file containing commands that Docker understands. See the example shown below:

FROM debian:buster

RUN apt-get update
RUN apt-get -y install build-essential

The FROM command indicates a base image to use, in this case debian:buster. Next we use a series of RUN commands to run commands as if we were at the terminal. In this case we run apt-get update to update our packages in Debian. Finally we install the build-essential package which includes make, gcc, etc.

We can run docker build . from the directory containing the Dockerfile. This will create an image based on the contents of our Dockerfile and output the hash of the resulting image. We can view the various images with the docker images command:

REPOSITORY   TAG       IMAGE ID       CREATED          SIZE
<none>       <none>    8c470891703a   10 minutes ago   354MB

Now we can run that image and poke around in a bash shell. To do this we need to pass certain flags to the run command: i for interactive and t to allocate a tty. Putting it all together, we get: docker run -it 8c470891703a.

root@06292e5e2a27:/#

Wow, we're the root user in our new host. Let's check the version of g++:

root@06292e5e2a27:/# g++ --version
g++ (Debian 8.3.0-6) 8.3.0
Copyright (C) 2018 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

root@06292e5e2a27:/# exit

Please see the link at the top of this section for more information.

Clone this wiki locally